Ansible could play in two mechanism :
- using ad-hoc command, useful for simple command
- using playbook, more complicated
First you have to install it form here.
Here is some clue to starting Ansible :
HOST
- config host ini /etc/ansible/hosts or using -i inverntory.ini
- ansible_user=root default using ssh user
- ansible_ssh_common_args='-o StrictHostKeyChecking=no' for disable from known host
- ansible_ssh_private_key_file: "/home/ansible/.ssh/id_rsa"
- [group]
- [group:children] include from above group
- [group:vars] var for ansible
Ad-Hoc COMMAND
ansible -i inventory -m module -a "argument"
Ping
ansible servers -m ping -i inventory.ini -b{ecome}
Systemctl
ansible all -m systemd -a "name=nginx state=started" -i inventory.ini -s
YUM
ansible loc -m yum -a "name=nginx state=present update_cache=true" -i inventory.ini -s
ansible loc -m yum -a "name=nginx state=absent" -i inventory.ini -b
No comments:
Post a Comment