Skip to content

peterweissdk/ansible

Repository files navigation

Ansible

... a suite of software tools that enables infrastructure as code.

Ansible playbooks for my personal use...

Ansible documentation: https://docs.ansible.com/ This setup is testet in my production enviroment. Please adjust to your own enviroment and preferences.

Hardware setup

My server setup setup:

  • Ubuntu 22.04
  • Raspberry Pi v. [1, 2, 3, 4]
  • Intel Nuc

My Ansible host setup:

  • Arch Linux
  • Generic laptop

Installation

Install OpenSSH and corresponding ssh-keys at your servers

sudo apt install openssh-server

Install Ansible

pacman -S ansible-core

Ajust hosts and ansible.cfg in /etc/ansible/ to your needs

Check if all the nodes listed in the inventory are alive by running the command below

$ ansible all -m ping

Ansible cmd examples

Dry run

$ ansible-playbook -K update_pb.yml --extra-vars="nodes=<HOST>" --check

Update server single node or group in HOST

$ ansible-playbook -K update_pb.yml --extra-vars="nodes=<HOST>"

Install with apt on server single node or group in HOST

$ ansible-playbook apt-install_pb.yml -K --extra-vars="nodes=<HOST>, package=<PACKAGE>"

Remove PACKAGE with apt on server single node or group in HOST

$ ansible-playbook apt-remove_pb.yml -K --extra-vars="nodes=<HOST>, package=<PACKAGE>"

Skip HOST in inventory group

$ ansible-playbook ping-all_pb.yml --limit '!<HOST>'

List the inventory in a "graph" way

$ ansible-inventory --graph -i hosts

Note!!!

Ansible {options] :

  • -K -> elevate user calling sudo
  • -l -> runs specific group from inventory file
  • -i -> path to inventory file
  • --check -> dry run
  • --limit -> override og add spicific host to use with playbook

License

Free Software... But of Course!

Copyright [2023] [PeterWeissDK]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

I used Apostrophe to create this file

Releases

No releases published

Packages

No packages published