8000 GitHub - Gwerlas/system · GitHub
[go: up one dir, main page]

Skip to content
GwerlasPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Base system

pipeline status

Linux systems base settings.

Running roles in containers is not common, but this use case is supported for Ansible testing with Molecule. When it detects a container, the role leaves to the container engine what belongs to it : host names, firewall, clock, sudo, sshd and reboots are not managed. Everything else still applies — package managers, packages, users, CA certificates.

GitLab project: yoanncolin/ansible/roles/system

Requirements

This role has been written to be run as a non root user, so Sudo has to be installed and configured. It requires ansible-core 2.19 or above.

It uses the ansible.posix, ansible.utils and community.general collections. Installing the role does not install them: they are listed in the requirements.yml shipped with it.

ansible-galaxy collection install -r requirements.yml

On the controller, the role needs the jmespath Python package, and network configuration the netaddr one too.

Facts

Defined facts of this role :

  • system_boot_mode
  • system_kernel
  • system_mounts
  • system_needs_reboot
  • system_packages
  • system_services
  • system_shells
  • system_uptime

Look at the facts documentation for more details.

Tags

Some values are dispatched in multiple tasks, so You can quickly update them with tags :

  • ca - SSL certificates authorities
  • firewall
  • hosts - Update /etc/hosts file
  • networks
  • package-managers
  • packages
  • proxies
  • remote-access
  • ssh
  • storages
  • sudoers
  • time
  • users

Usage :

ansible-playbook -t tag1[,tag2[,...]] my_play.yml

Check mode

--check --diff shows what the role would change on a host and changes nothing. Commands that only look at the host still run — the reboot detection, the age of the package index, the Portage profile in use — so what the role reports rests on the host's real state. Commands that act, a Portage sync or the cleanup of old kernels for instance, are skipped.

Tasks

System components are managed through separated tasks that could be called independently.

Of course, all tasks are called in the main.yml. See each task documentation :

Role Variables

Feature flipping

Look at defaults/main/feature-flipping.yml.

Enable/disable some features by setting them to true/false.

Tasks sequence

Some tasks may depend on another one. For example, storage and network management may require the installation of packages, but packages are fetched through the network and stored on disk.

You can change the installation sequence for your specific situation defining the system_sequence variable.

Here is the default sequence :

system_sequence:
  - modules
  - proxies
  - hosts
  - sudo
  - package-managers
  - packages
  - networks
  - storages
  - users
  - ca
  - time
  - firewall
  - remote-access

Note that the facts task is implicitly called by the other tasks if needed.

Common variables

Look at defaults/main/common.yml.

system_scripts_path: /usr/local/bin
system_profile: server

Some tasks of this role need to put scripts. They are stored in the system_scripts_path directory.

The system_profile can impact the behaviour of some parts of the system, for example the packages to install (or not). It is a / separated path, each segment adding to the ones before it :

Segment What it adds
server nothing of its own — the default
desktop LibreOffice, Firefox and usbutils, plus the Yay AUR helper on ArchLinux
gnome the GNOME session, its utilities and the gdm service
hardened a hardened sshd configuration, replacing the distribution one

Whatever the profile, every node gets acl, sudo and rsync. The usual combinations :

system_profile: server                  # the default
system_profile: server/hardened
system_profile: desktop
system_profile: desktop/gnome
system_profile: desktop/gnome/hardened

A segment naming none of the profiles above brings nothing. It is ignored, and said so in the play output rather than dropped silently :

TASK [gwerlas.system : Facts - Report unknown system_profile segments] *****
[WARNING]: [node] system_profile segment(s) gnom match no known profile and
are ignored (available: desktop, gnome, hardened, server)
ok: [node]

Dependencies

A reachable Linux system with Python installed.

Example Playbook

First deployment or distribution upgrade, 10 steps rolling update :

---
- name: Rolling update
  hosts: all
  serial: 10%
  roles:
    - role: gwerlas.system
      vars:
        system_packages_upgrade: true

Using just one task :

---
- name: Package managers
  hosts: all
  tasks:
    - name: Just get the package manager upready
      ansible.builtin.import_role:
        name: gwerlas.system
        tasks_from: package-managers

License

BSD 3-Clause License.

About

No description, website, or topics provided.

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0