python - Processing vars in playbook -


i want make script setup tinc vpn between computer instances. need way pass through command line of "/tmp/setup_tinc.py" following args:

--connect-to %{{ ' '.join( groups['do'] }}% 

where %{{ part }}% interpreted in python. can't seem find way this. can me fix code ?

i made following playbook:

- name: tinc install & setup   hosts:   user: root   vars:     tincnet: cloudnet   tasks:   - name: install tinc package     action: command apt-get install tinc python-argparse -y   - name: copy tinc setup script     action: copy src=setup_tinc.py dest=/tmp/setup_tinc.py mode=755   - name: run tinc setup script     action: command /tmp/setup_tinc.py --network $tincnet --tinc-ip $tinc_ip --hostname     $hostname   - name: fetch tinc file     action: fetch src=/etc/tinc/$tincnet/hosts/$hostname dst=hosts   - name: adding firewall rule     action: command ufw allow 514 

in ansible 1.1 , earlier little tricky do. can't in-line python code in playbooks can in templates. news is, few feature in latest codebase on github (to released version 1.2) allows jinja2-style templating in playbooks well! check thread out:

https://groups.google.com/forum/#!topic/ansible-project/gb3abietgta

so means you'll able do:

--connect-to {{ ' '.join( groups['do'] }}

...right in playbook if you're using latest github code.

hope helps!


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -