This content originally appeared on DEV Community and was authored by Santhosh Balasa
-> Command to validate Ansible playbook syntax:
ansible-playbook <playbook.yml> --syntax-check
-> Sample playbook to run command in localhost:
---
- name:Sample Ansible playbook
hosts: 127.0.0.1
connection: local
tasks:
- name: Display hostname
command: hostname
register: out
- debug: var=out.stdout_lines
-> Run a playbook:
ansible-playbook <playbook.yml>
-> Run multiple commands using playbook:
---
- name: Run multiple commands
hosts: 127.0.0.1
connection: local
vars:
unix_command: ls
tasks:
- name: Display name of the host
command: hostname
register: task1
- name: Execute {{ unix_command }}
command: {{ unix_command }}
register: task2
- debug: var=task1.stdout_lines
- debug: var=task2.stdout_lines
This content originally appeared on DEV Community and was authored by Santhosh Balasa
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
Santhosh Balasa | Sciencx (2021-05-31T03:54:46+00:00) Using Ansible. Retrieved from https://www.scien.cx/2021/05/31/using-ansible/
" » Using Ansible." Santhosh Balasa | Sciencx - Monday May 31, 2021, https://www.scien.cx/2021/05/31/using-ansible/
HARVARDSanthosh Balasa | Sciencx Monday May 31, 2021 » Using Ansible., viewed ,<https://www.scien.cx/2021/05/31/using-ansible/>
VANCOUVERSanthosh Balasa | Sciencx - » Using Ansible. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/31/using-ansible/
CHICAGO" » Using Ansible." Santhosh Balasa | Sciencx - Accessed . https://www.scien.cx/2021/05/31/using-ansible/
IEEE" » Using Ansible." Santhosh Balasa | Sciencx [Online]. Available: https://www.scien.cx/2021/05/31/using-ansible/. [Accessed: ]
rf:citation » Using Ansible | Santhosh Balasa | Sciencx | https://www.scien.cx/2021/05/31/using-ansible/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.