Ich versuche, Vars in meinem Ansible Playbook zu verwenden. ENV
wird als Eingabe von der Befehlszeile übergeben.Verwenden von Vars als Argument in Ansible
---
- hosts: development
sudo: yes
sudo_user: root
vars:
env: "{{ ENV|default('DEV') }}"
roles:
# Copy conf files
- { role: copy, src: ./conf/ems/7000/"{{ env }}"/*.conf , dest: /apps/tibco/config/ems/7000/data/ }
- { role: copy, src: ./conf/ems/7000/"{{ env }}"/*.conf , dest: /apps/tibco/config/ems/7200/data/ }
- { role: copy, src: ./conf/ems/7000/"{{ env }}"/*.conf , dest: /apps/tibco/config/ems/7004/data/ }
Ich betreibe dieses Textbuch durch den Befehl
ansible-playbook -e 'ENV=DEV' --ask-sudo-pass install-ems-plybook.yml
ich
# Copy conf files
- { role: copy, src: ./conf/ems/7000/" {{env}} "/*.conf , dest: /apps/tibco/config/ems/7000/data/ }
^
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
Bitte explizit in Antwort sein, wie ich noch ein Kleinkind in ansible bin.
wird in 1,9 der tans_user unterstützt? –
Ja, nach [docs] (https://docs.ansible.com/ansible/become.html#for-those-from-pre-1-9-sudo-and-su-still-work) 'werden' -Parameter wurden in 1.9 eingeführt. – techraf