Giter Club home page Giter Club logo

ansible-collection-rhel's Introduction

Ansible Collection - epfl_si.rhel

Collection of Ansible roles to setup and manage components of RHEL like sshd, users, sudo,...

Goal and target audience

The goal is to help system administrators install and configure their RHEL servers.

You are welcome to suggest improvements either by opening a issue or via a pull request.

This collection was created before we came across https://github.com/linux-system-roles. We will periodically evaluate their progress and eventually use some of their roles.

How to include the collection

In your playbook repository, add this to the collections/requirements.yml file:

---
collections:
  - name: epfl_si.rhel
    version: 2.1.2

Be sure to add the path you want to download collections to is present in your ansible.cfg file:

[defaults]
collections_path = ./collections:~/.ansible/collections/ansible_collections

Then run:

ansible-galaxy collection install -r collections/requirements.yml --collections-path ./collections

Roles documentation

Each role has it's own README.md

Testing

Install Ansible Controller

On the controller node, we prefer to use a virtualenv:

sudo yum install python3.8 python3-virtualenv
mkdir -p ~/python-venv/ansible-8.1.0
virtualenv --python=python3.8 ~/python-venv/ansible-8.1.0
source ~/python-venv/ansible-8.1.0/bin/activate
python -m  pip install --upgrade pip
pip install \
  ansible==8.1.0 \
  ansible-lint \
  antsibull-changelog \
  molecule \
  molecule-podman \
  yamllint \
  selinux \
  psutil \
  argcomplete \
  boto3

Run tests

Tests are done using Molecule with the Podman driver. Because we wants to test communications between containers using IP address, we must use rootfull containers.

When writing this, Ansible collections are fairly new and the question about how to update and test roles inside a collection is still discussed by the community. Also, this repository is hosted on GitHub but we only have experience with Gitlab CI. So adaptations could be necessary in the future.

In order to run Systemd services inside Podman, we must mount various volumes, disabling Selinux labeling and add capabilities:

---
platforms:
  - name: node1
    registry: {url: registry.access.redhat.com}
    image: ubi8/ubi-init
    tmpfs:
      - /run  # for SystemD
      - /tmp  # for SystemD
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro  # for SystemD
    capabilities:
      - SYS_ADMIN  # for SystemD
      - NET_ADMIN  # for FirewallD + VIP testing
    command: "/usr/sbin/init"
    security_opts:
      - label=disable  # for SystemD

Each role contains its own tests. To use Molecule:

sudo -i  # Remember, we need rootfull containers
source ~/python-venv/ansible-8.1.0/bin/activate
cd roles/<name>
molecule test -s <scenario>

If you want a running environement to debug your changes:

sudo -i
source ~/python-venv/ansible-8.1.0/bin/activate
cd roles/<name>
molecule converge -s <scenario>
molecule login -s <scenario> -h <node-name>

Publishing

ATM, no automation, everything is done from your computer. To find your token, go to https://galaxy.ansible.com/me/preferences

  1. Bump the version in galaxy.yml
  2. source ~/python-venv/ansible-8.1.0/bin/activate
  3. antsibull-changelog lint
  4. antsibull-changelog release --version <ver>
  5. git add .
  6. git commit -m "Release version <ver>"
  7. git tag <ver>
  8. ansible-galaxy collection build
  9. ansible-galaxy collection publish ./epfl_si-rhel-<ver>.tar.gz --token=<token>
  10. rm ./epfl_si-rhel-<ver>.tar.gz
  11. git push --tags

ansible-collection-rhel's People

Contributors

laurent-indermuehle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.