Ways of Working – Ansible
- Ensure you have list of all the steps (commands) which are working.
- Take each command find equivelent module in Ansible
- Write a playbook (yaml) where we list the modules in a specific structure.
Summary
- We need to know the playbook format i.e. YAML
- Expressing modules in YAML form
Finding equivelent modules for commands in Ansible
- Ansible has a very large set of modules
- In addition to these modules ansible has a larger community of third party reusable assets
- To find the right module lets do the exercise
Lets look at website installation steps
sudo apt update
sudo apt install nginx -y
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
sudo apt install unzip
cd /tmp
wget https://templatemo.com/tm-zip-files-2020/templatemo_589_lugx_gaming.zip
unzip templatemo_589_lugx_gaming.zip
cd templatemo_589_lugx_gaming/
sudo cp --recursive . /var/www/html/
- Google for
<command> in ansible will work for 90% of the cases.
sudo apt update => apt update => command is apt action is update
sudo apt install nginx -y => apt => command install is action
ping google.com
systemctl restart nginx
command <args>

- Module name

-
Parameters
-
Examples: Will give basic usage
-
Prompt to understand command
You are linux expert, i will give you the command and explain what it does breifly
Lets list out command, equivelent module and necessary parameters
| Command |
Module |
Parameters |
| apt update |
ansible.builtin.apt |
update_cache => true |
| apt install nginx |
ansible.builtin.apt |
state => present, name => nginx |
| systemctl enable nginx.service |
ansible.builtin.systemd_service |
enabled => true, name => nginx.service |
| sudo systemctl start nginx.service |
ansible.builtin.systemd_service |
name => nginx.service, state => started |
| apt install unzip |
|
|
| wget https://templatemo.com/tm-zip-files-2020/templatemo_589_lugx_gaming.zip |
ansible.builtin.get_url |
url, dest => /tmp/templatemo_589_lugx_gaming.zip.zip |
| unzip templatemo_589_lugx_gaming.zip |
ansible.builtin.unarchive |
src => url, remote_src => true, dest => /var/www/html/ |
- Exercise: Findout steps to install tomcat 10 with openjdk 21 on ubuntu server and comeup with this table.
Like this:
Like Loading...