diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef664fc..6af84de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,3 +19,19 @@ jobs: # uses: mxschmitt/action-tmate@v3.5 - name: Test using Molecule run: molecule test + test-rocky8: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install Molecule + run: | + pip install -U pip setuptools wheel + pip install -r requirements-dev-rocky8.txt + # - name: Debugging with tmate + # uses: mxschmitt/action-tmate@v3.5 + - name: Test using Molecule + run: molecule test -s rocky8 diff --git a/molecule/rocky8/Dockerfile.j2 b/molecule/rocky8/Dockerfile.j2 new file mode 100644 index 0000000..0b331c5 --- /dev/null +++ b/molecule/rocky8/Dockerfile.j2 @@ -0,0 +1,23 @@ +# Molecule managed + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +{% if item.env is defined %} +{% for var, value in item.env.items() %} +{% if value %} +ENV {{ var }} {{ value }} +{% endif %} +{% endfor %} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 python3-pip sudo bash ca-certificates iproute2 python3-apt aptitude && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash iproute && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ + elif [ $(command -v pacman) ]; then pacman --noconfirm -Suy python python-pip sudo openssh; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi diff --git a/molecule/rocky8/INSTALL.rst b/molecule/rocky8/INSTALL.rst new file mode 100644 index 0000000..6a44bde --- /dev/null +++ b/molecule/rocky8/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ pip install 'molecule[docker]' diff --git a/molecule/rocky8/converge.yml b/molecule/rocky8/converge.yml new file mode 100644 index 0000000..e0108e3 --- /dev/null +++ b/molecule/rocky8/converge.yml @@ -0,0 +1,55 @@ +--- +- name: Converge + hosts: all + pre_tasks: + - name: Set ssh server package name for non-Archlinux ansible_os_family + set_fact: + openssh_package: "openssh-server" + pip3_extra_args: "" + when: ansible_os_family != "Archlinux" + + - name: Set ssh server package name and pip3 argument for Archlinux ansible_os_family + set_fact: + openssh_package: "openssh" + pip3_extra_args: "--break-system-packages" + when: ansible_os_family == "Archlinux" + + - name: Install openssh + package: + name: "{{ openssh_package }}" + state: present + + - name: Enable EPEL for yamllint + package: + name: epel-release + state: present + when: ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora' + + - name: Install yamllint + package: + name: yamllint + state: present + + roles: + - role: borgbase.ansible_role_borgbackup + borg_install_method: pip + borgmatic_timer: cron + borg_repository: m5vz9gp4@m5vz9gp4.repo.borgbase.com:repo + borg_encryption_passphrase: CHANGEME + borg_source_directories: + - /srv/www + - /var/lib/automysqlbackup + borg_exclude_patterns: + - /srv/www/old-sites + borg_retention_policy: + keep_hourly: 3 + keep_daily: 7 + keep_weekly: 4 + keep_monthly: 6 + borgmatic_hooks: + before_backup: + - echo "`date` - Starting backup." + postgresql_databases: + - name: users + hostname: database1.example.org + port: 5433 diff --git a/molecule/rocky8/molecule.yml b/molecule/rocky8/molecule.yml new file mode 100644 index 0000000..bfb867e --- /dev/null +++ b/molecule/rocky8/molecule.yml @@ -0,0 +1,16 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: rockylinux-8 + image: rockylinux/rockylinux:8 +provisioner: + name: ansible +verifier: + name: ansible +lint: | + set -e + yamllint . + ansible-lint . diff --git a/molecule/rocky8/verify.yml b/molecule/rocky8/verify.yml new file mode 100644 index 0000000..f816e3f --- /dev/null +++ b/molecule/rocky8/verify.yml @@ -0,0 +1,13 @@ +--- +- name: Verify + hosts: all + tasks: + - name: Ensure Borgmatic is installed correctly + command: borgmatic --version + + - name: Ensure Borg is installed correctly + command: borgmatic borg --version + + - name: Ensure produced YAML is valid + command: | + yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" /etc/borgmatic/config.yaml diff --git a/requirements-dev-rocky8.txt b/requirements-dev-rocky8.txt new file mode 100644 index 0000000..50d35e5 --- /dev/null +++ b/requirements-dev-rocky8.txt @@ -0,0 +1,4 @@ +ansible<10 +ansible-lint +molecule +molecule-plugins[docker]