linux-system-roles / .github

Common github actions for the linux-system-roles organization
MIT License
1 stars 8 forks source link

.github - common file and configuration management for system roles

The configuration source for linux-system-roles repositories. This uses Ansible to manage configuration, github actions, and other common files used by repositories in the linux-system-roles organization. This allows org admins to easily rollout updates to all repos.

File structure

The structure of the files/directories under playbooks/files and playbooks/templates should match exactly the name and location of the files/directories in the role repositories. For example, playbooks/templates/.ansible-lint corresponds to the .ansible-lint file in the root directory of the role repositories. playbooks/.github/workflows/weekly_ci.yml corresponds to the file .github/workflows/weekly_ci.yml in the role repositories.

The file inventory.yml is the list of all roles and contains the groups active_roles for all of the actively maintained and supported roles, and the group python_roles for the roles that provide Ansible python plugins such as modules, filters, etc.

The file inventory/group_vars/active_roles.yml is used for settings common to all roles.

The file inventory/group_vars/python_roles.yml is used for settings common to all roles that have python modules, filters, and other Ansible plugin python code.

The file inventory/host_vars/$ROLENAME.yml is used for settings that are specific to that role. Some examples:

Add a new role

all:
  hosts:
    ...
    postgresql:
      ansible_host: localhost
    quite_a_good_new_role:
      ansible_host: localhost
    rhc:
      ansible_host: localhost
        postgresql:
        quite_a_good_new_role:
        rhc:
        network:
        quite_a_good_new_role:
        selinux:

Add a new config or github action file

Add the file according to the location in the role repository under playbooks/files or playbooks/templates. If the file is static, and needs no per-role configuration (such as a github action cron schedule), then add under playbooks/files.

NOTE: github action files will almost always be templates, due to the checkout action being template-ized.

present_templates are files that should be present in all roles that are generated by templates. present_files are files that should be present in all roles that are static. absent_files are files that should be removed from all roles. present_python_templates are files that should be present in roles that provide Ansible python code that are generated by templates. present_python_files are files that should be present in roles that provide Ansible python code that are static. absent_python_files are files that should be removed from roles that provide Ansible python code.

Preparing for using the automation

This uses the gh command line tool provided by the gh package on Fedora. To configure Github tools to run the automation, complete the following steps:

Creating PRs in every role with updated files

The playbook playbooks/update_files.yml will create PRs in all roles with the new/updated/deleted files. If you just want to see what the playbook will do without actually creating anything on github, add -e lsr_dry_run=true to the ansible-playbook command.

Parameters

Run it

Run it like this:

ansible-playbook -vv -i inventory -e lsr_dry_run=false \
  -e update_files_branch=my_update_branch -e exclude_roles=nbde_client \
  -e test_dir=/var/tmp/lsr \
  -e update_files_commit_file=/path/to/git-commit-msg playbooks/update_files.yml

How it works

NOTE: This process may create multiple commits if you need to make edits to an existing PR. Use the Squash commits and merge functionality in the github PR to merge.