Reputation: 105
I am completely new to ansible, and I have multiple arguments to pass to the YAML as below:
ansible-playbook parse.yaml -e hi,hello
The YAML should split the 'hi,hello' without the delimiters one after the other:
hi
hello
I have searched through many web pages but I couldn't find anything helpful, is it even possible to do so?
Upvotes: 0
Views: 640
Reputation: 412
It's simple
ansible-playbook -i hosts playbook.yml -e 'parameter1=hi parameter2=hello'
For nice output you can add "| sed 's/\n/\n/g'"
ansible-playbook -i hosts playbook.yml -e 'parameter1=hi parameter2=hello'| sed 's/\\n/\n/g'
cat ./hosts:
localhost
cat playbook.yml:
---
- name: Playbook
hosts: all
become: root
tasks:
- name: output parameter1
debug: msg="{{ parameter1 }}"
- name: output parameter2
debug: msg="{{ parameter2 }}"
- name: output both
debug:
msg: |
{{ parameter1 }}
{{ parameter2 }}
Upvotes: 1