Anyone who is interested in operating machines remotely, having basic knwledge of linux can follow these steps to learn Ansible, and perform interesting set of operations remotely.
- Introduction
- Basic implementation
- Flow control in playbook
- Way to Implement large Automation
- Ansible GUI
- Advance
- References
---- Let's Start ----------------------------------------------
- Ansible quickstart
- YAML basics
- Terminology
- Installation
- How ansible work
- Getting started
- First Innevtory
- Ansible config file precedence
- Ad hoc commands
- Run first playbook
- Working with modules
- Ansible connection
- Register variables
- Ansible Vault
- setup module to gather facts
- Special variables
- Ansible actions/Meta
- Require 2 vm in same network
- Install ansible on 1st (host vm)
- Make sure python is available on 2nd (remote vm)
- Setup text editor for ansible yaml (eg for vim add
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
in $HOME/.vimrc) - Create two users ansible_password and ansible_key in remote vm (without granting sudo access) and make sure st user is accessavle by ssh username and password, and for 2nd user ansible_key generate a new public private key private key parir and try to login here by ssh using private key
- Write a adhoc command to gather facts of localhost using setup module and try to get specific value using filter attribute of setup module
- Write Adhoc command to copy any file to suitable path of remote machine/vm whose IP specified in inventory present in the current directory
1. To override values in ansible.cfg for single usecase, copy ansible.cfg to current directory, configure absolute or relative path of inventory in ansible.cfg . Learn to configure the connection from inventory, either connect remote machine by it's ssh username and passsweod or connect by private key of ssh account
- Write a playbook to create a file in ansible on host machine (where ansible is running), which contain IP address of host machine all this in 1st play of the playbook and 2nd play should copy this file from this host machine to remote machine
1. Check ansible_connection = local // for faster connection on localhost
2. Explore remote_src option of copy module
- Explore and use following frequently used modules from official Ansible doc
- debug
- set_fact
- copy
- synchronize
- file
- lineinfile
- fetch
- path
- package
- uri
- shell/command
- service
- add_host
- user/group
- conditionals
- Looping
- Filters
- Task delegation
- Include and Import
- privilege escalation
- Jinja templating
- Input from console
1. (If 2 remote vm are available) You are running ansible on host machine 'say 'A', now write a playbook to create 5 different files (named 'a', 'b', 'c', 'd', 'e') on remote machine 'say B' and copy all this files to remote machine 'say C' directly from 'B' to 'C'.
2. Write a playbook in ansible to install httpd or nginx on remote vm,
generate a index.html file which will be hosted later,
content of this file should be IP address and hostname of the remote vm (where file will be hosted),
copy this file on appropriate path of remote vm and start the service,
edit "etc/hosts" of host to access remote server with custom name,
check the status code of the newly hosted webpage using URI module get request.
3. Copy a file from single host present in inventory group called "webserver" to remaining hosts mentioned in inventory in (under all other groups)
- deploy awx container and try to run playbook directly from git to any machine in local network
Explore: inventory, projects, credentials(machine and vault), template(job and workflow), Jobs(logging)
- Host pattern
- Writting python logic in ansible
- Custom modules, more examples check existing moudule from configured path written in both python and powershell
- Dynamic inventory Working, Development
- Data Manipulation
- Testing framework in ansible Molecule
- Connect remote windows host doc, add_host
- https://docs.ansible.com/
- https://medium.com/@me.sanjeev3d/ansible-configuration-management-945b56eed6d7
- https://github.com/ansible/ansible-examples
- https://docs.ansible.com/ansible/2.4/intro_configuration.html
- https://docs.ansible.com/ansible/latest/dev_guide/overview_architecture.html
- https://docs.ansible.com/ansible/latest/cli/ansible.html