/ansible-linux-postinstall

Ansible role. Post-install configuration of Linux.

Primary LanguageShellBSD 2-Clause "Simplified" LicenseBSD-2-Clause

linux_postinstall

Build Status

Ansible role.

Configure Linux: acpi, aliases, apparmor, authorized keys, autofs, automatic upgrades, bluetooth, cron, debsums, fstab, gpsd, grub, hostname, hosts, iptables, kvm, latex, libvirt, lid, logrotate, modem manager, modules, netplan, nfsd, packages, pm-utils, postfix, repos, service, smart, speech-dispatcher, ssh, sshd, sudoers, swap, sysctl, timesyncd, timezone, tlp, udev, ufw, users, virtualbox, wpa_gui, wpa_supplicant, xen, xorg.conf.d, zfs, (wip ...)

Tested systems:

  • Ubuntu 18.04
  • Ubuntu 19.04
  • CentOS 7
  • Armbian 5.90

Please feel free to share your feedback and report issues.

Requirements

None.

Variables

Read the defaults and examples in vars.

Workflow

  1. Install the role.
# ansible-galaxy install vbotka.linux_postinstall
  1. Change variables.
# editor vbotka.linux_postinstall/vars/main.yml
  • Review OS specific variables in vars/defaults.
  • Review, customize and/or add Flavor specific variables in vars/flavors.
  • Optionally disable lp_flavors_enable: false. This will speedup the playbook.
  • Optionally put customized OS specific variables into the vars directory.
  • See tasks/vars.yml for the naming conventions and precedence.
  • Os specific variables will overwrite variables in var/main.yml.
  1. Create the inventory.
# cat hosts
[host1]
host1.example.com
[host1:vars]
ansible_user: admin
ansible_connection=ssh
ansible_python_interpreter=/usr/bin/python3.6
ansible_perl_interpreter=/usr/bin/perl
  1. Create the playbook.
# cat linux-postinstall.yml
- hosts: host1
  become: yes
  become_user: root
  become_method: sudo
  roles:
    - vbotka.linux_postinstall
  1. Run the playbook.
# ansible-playbook linux-postinstall.yml

Best practice

Perform syntax check of the playbook

# ansible-playbook linux-postinstall.yml --syntax-check

Run the playbook in in check mode first

# ansible-playbook linux-postinstall.yml --check

If all is right run the playbook twice. In second run all tasks shall be OK and 0 changed, unreachable and failed.

# ansible-playbook linux-postinstall.yml

Auto-installation of packages

Packages listed in the variables lp_*_packages will be automatically installed by the tasks/packages.yml if enabled by variable lp_* . For example

lp_libvirt: true
lp_libvirt_packages:
  - libvirt0
  - libvirt-bin
  - libvirt-daemon
  - libvirt-daemon-driver-storage-rbd
  - libvirt-daemon-system
  - virtinst

the lp_libvirt_packages will be included in the packages installed by

# ansible-playbook linux-postinstall.yml -t lp_packages

Auto-management of services

Variable lp_service_enable contains a list of services automatically managed by the task service.yml. A service will be manged by the task service.yml if lp_<service>: true. Setting lp_<service>: false will disable management of the service by the task service.yml. Variable lp_<service>_enable controls the status of the service. For example service udev will be enabled, because it is listed among lp_service_enable and by default

lp_udev: true
lp_udev_enable: true

Run the following command to see what services will be managed.

# ansible-playbook linux-postinstall.yml -e lp_service_debug=true -t lp_service_debug

See service.yml for details.

Recommended configuration after the installation of OS

  1. Configure users, sudoers and persistent network interfaces
ansible-playbook linux-postinstall.yml -t lp_hostname                                              
ansible-playbook linux-postinstall.yml -t lp_users
ansible-playbook linux-postinstall.yml -t lp_sudoers
ansible-playbook linux-postinstall.yml -t lp_udev                                                  
ansible-playbook linux-postinstall.yml -t lp_netplan                                               
ansible-playbook linux-postinstall.yml -t lp_wpasupplicant                                         
ansible-playbook linux-postinstall.yml -t lp_reboot -e 'lp_reboot=true lp_reboot_force=true'       
  1. Configure the firewall. For example iptables
# ansible-playbook linux-postinstall.yml -t lp_iptables
  1. Test installation of the packages
ansible-playbook -t lp_packages -e 'lp_package_install_dryrun=true' linux-postinstall.yml
  1. Install packages
ansible-playbook -t lp_packages linux-postinstall.yml
  1. Check, install and configure other tasks
ansible-playbook linux-postinstall.yml --check
ansible-playbook linux-postinstall.yml

License

license

Author Information

Vladimir Botka

References