Ansible
inventories in ansible
- Ansible inventory is collection of nodes and is of two types
- static inventory: we specify ip’s or names
- dynamic inventory: we execute the script to get ips or names dynamically
- Static inventory can be specified in two formats Refer Here
- ini format
- yaml format
Ansible facts
- Ansible collects the information about the node by executing a module
setup Refer Here
- setup module Refer Here
Ansible conditionals
Ansible adhoc commands
ansible -i hosts -m "<module-name>" -a "<argumets/parameters>" all
ansible.builts.file:
path: /tmp/1.txt
state: touch
ansible -i hosts -m "file" -a "path=/tmp/1.txt state=touch"
Activity 2: Work with different distributions
-
Install apache server on redhat and ubuntu
-
manual steps for ubuntu
sudo apt update
sudo apt install apache2 -y
sudo dnf install httpd -y
sudo systemctl enable httpd
sudo systemctl start httpd
- To install apache on both redhat and ubuntu
- Note:
- on redhat ssh conf
/etc/ssh/sshd_config.d/50-cloud-init.conf
- service name on redhat
sshd
- Refer Here for the changes done.