Wednesday 27 April 2022

Install Ansible on Ubuntu 22.04 and Configure in the user/current Directory


sudo apt install -f

sudo apt install software-properties-common

sudo apt-add-repository ppa:ansible/ansible

sudo apt update

sudo apt install ansible


ansible --version

ansible [core 2.12.4]

  config file = /etc/ansible/ansible.cfg


Configure ansible in the current directory /home/ansible

cat ansible.cfg

[defaults]

inventory - /home/ansible/inventory


cat inventory

controller


ansible --version

ansible [core 2.12.4]

  config file = /home/ansible/ansible.cfg


hostname -i

sudo hostnamectl set-hostname controller

exec bash

hostname


sudo echo "192.168.182.131 controller" | sudo tee -a /etc/hosts

192.168.182.131 controller

cat /etc/hosts


ansible all --list

  hosts (1):

    controller


#run "sudo apt install" if  Failed sudo: a password is required

#hosts: localhost, in playbook 

ansible-playbook install.yml


No comments:

Post a Comment