Skip to content

Ansible

Ansible

Configurations

Use Password (ansible.cfg):

#Enable Password auth
hsot_key_checking = False

Hosts File

Host Configurations:

[linux]

10.10.1.12
10.10.1.13


[linux:vars]
ansible_user=root
ansible_password=root

Modules

Run a Module:

ansible linux -m ping
ansible linux -m reboot

Run a Command:

ansible linux -a "cat /etc/hosts"

Run a Module:

ansible linux -m comunity.general.shutdown -b

Playbook

Example playbook:

---
	- name: test
	  hosts: linux
	  tasks:
	  	- name: Ensure nvim installed
	  	  yum: 
	  	    name: neovim
	  	    state: latest

Run Playbook:

ansible neovim.yml