AnsibleΒΆ
InstallationΒΆ
UbuntuΒΆ
Install ansible on ubuntu servers
sudo apt update --yes
sudo apt install --yes software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install --yes ansible
DebianΒΆ
Signing key
UBUNTU_CODENAME=jammy
wget -O- "https://keyserver.ubuntu.com/pks/lookup?fingerprint=on&op=get&search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367" | sudo gpg --dearmour -o /usr/share/keyrings/ansible-archive-keyring.gpg
Add an entry to aptβs sources pointing to the PPA
echo "deb [signed-by=/usr/share/keyrings/ansible-archive-keyring.gpg] http://ppa.launchpad.net/ansible/ansible/ubuntu $UBUNTU_CODENAME main" | sudo tee /etc/apt/sources.list.d/ansible.list
Update and install from apt repo
Arch LinuxΒΆ
To install the full ansible package run
To install the minimal ansible-core package run
Test for Correct InstallationΒΆ
PingPong with ansible
Show file systems
Putting arguments into your command
Install vim with ansible
We can specify multiple hosts by separating them with colons
Best Practice Ansible Project StructreΒΆ
.
βββ inventory
β βββ hosts
βββ prjct-name.yml
βββ roles
βββ prjct-name
βββ defaults
β βββ main.yml
βββ files
βββ handlers
β βββ main.yml
βββ meta
β βββ main.yml
βββ tasks
β βββ main.yml
βββ templates
βββ vars
βββ main.yml
- inventories: Contains information about your managed hosts and groups.
- hosts: Defines host names, IP addresses, and group memberships.
- group_vars: Holds variables shared by groups of hosts.
- prjct-name.yml: Your main playbook, orchestrating the execution of roles.
- defaults: Contains default variables for the role.
- files: Stores static files to be copied to remote hosts.
- handlers: Defines actions to be taken in response to certain changes.
- meta: Contains metadata about the role, including dependencies.
- tasks: Contains the main tasks to be executed by the role.
- templates: Stores Jinja2 templates for dynamic file generation.
- vars: Contains additional variables specific to the role.