What is ansible?
https://en.wikipedia.org/wiki/Ansible_(software)
Ansible commands for this and that
In no particular order.
Test run a playbook file
# ansible-playbook playbook.file.yml --check
Ad-hoc command
Run the command on all members in group centos. For CentOS this is set in /etc/ansible/hosts.
# ansible centos -a 'yum update -y'
Specify target groups in playbook
Specifying the below in the playbook, will run the commands on the two host groups centos-cli and centos-srv.
- hosts: centos-cli:centos-srv
Source: https://github.com/ansible/ansible/issues/3546#issuecomment-21024596
Create multiple users on multiple computers and distribute ssh-keys
See these:
http://ciscostuff.gurjap.org/user-ansible-create-multiple-users-authorize-ssh-keys
https://groups.google.com/forum/#!topic/ansible-project/t6dsaaxtTyo
https://www.howtoforge.com/tutorial/setup-new-user-and-ssh-key-authentication-using-ansible/
Variation with sudo privileges:
https://github.com/msergiy87/ansible-create-users.
Considerations when creating ssh key-pairs
https://serverfault.com/questions/910071/how-to-generate-host-ssh-keys-via-ansible
Run tasks step by step
Sometimes you don't want to run all tasks in a playbook. Should this be the case you can use the --step flag.
# playbook.yml
- hosts: centos-cli tasks: - name: first task # run some task - name: second task # run some other task
# ansible-playbook playbook.yml --step > Perform task: first task (y/n/c): n ... > Perform task: second task (y/n/c): y #
Source: http://codeheaven.io/15-things-you-should-know-about-ansible/
Using playbook debugger for logging per playbook
https://stackoverflow.com/questions/35135954/how-to-log-in-a-separate-file-per-playbook-in-ansible
https://groups.google.com/forum/#!msg/ansible-project/ql6xFaTDcYw/UwdkDuP7BQAJ
https://docs.ansible.com/ansible/latest/user_guide/playbooks_debugger.html
https://docs.ansible.com/ansible/latest/plugins/callback/log_plays.html
This notelett is a work in progress. Need to do some reading...
Sources
Various sources on the internet. See info inline above.