Ansible is a suite of software tools that enables infrastructure as code. It is open-source and the suite includes software provisioning, configuration management, and application deployment functionality
Install process here in follow link https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html#installing-ansible-on-specific-operating-systems
brew install ansible
Creation:
ssh-keygen
Install in selected server:
ssh-copy-id [email protected]
Create a file in /etc/ansible/hosts
with a content like:
[dev]
192.168.10.1
[prod]
192.168.30.1
ping:
ansible all -m ping
192.168.10.1 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
192.168.30.1 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
shell command:
ansible dev -m shell -a "/bin/echo hello"
192.168.10.1 | CHANGED | rc=0 >>
hello
shell command as root with ask password:
ansible all --become --ask-become-pass -m shell -a "sudo dmesg"