diff --git a/roles/create_backups/.yamllint b/roles/create_backups/.yamllint new file mode 100644 index 0000000..8827676 --- /dev/null +++ b/roles/create_backups/.yamllint @@ -0,0 +1,33 @@ +--- +# Based on ansible-lint config +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + colons: + max-spaces-after: -1 + level: error + commas: + max-spaces-after: -1 + level: error + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: + max: 3 + level: error + hyphens: + level: error + indentation: disable + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable + truthy: disable diff --git a/roles/create_backups/molecule/default/Dockerfile.j2 b/roles/create_backups/molecule/default/Dockerfile.j2 new file mode 100644 index 0000000..0de39e6 --- /dev/null +++ b/roles/create_backups/molecule/default/Dockerfile.j2 @@ -0,0 +1,22 @@ +# 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 python sudo bash ca-certificates iproute2 && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash iproute && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python 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 xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi diff --git a/roles/create_backups/molecule/default/INSTALL.rst b/roles/create_backups/molecule/default/INSTALL.rst new file mode 100644 index 0000000..6a44bde --- /dev/null +++ b/roles/create_backups/molecule/default/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/roles/create_backups/molecule/default/molecule.yml b/roles/create_backups/molecule/default/molecule.yml new file mode 100644 index 0000000..e1a8dce --- /dev/null +++ b/roles/create_backups/molecule/default/molecule.yml @@ -0,0 +1,24 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: amazon_linux2 + image: amazonlinux:2 + groups: + - aws_node_local + # - name: ubuntu_lts + # image: ubuntu:bionic + # groups: + # - aws_node_local +provisioner: + name: ansible + lint: + name: ansible-lint +verifier: + name: testinfra + lint: + name: flake8 diff --git a/roles/create_backups/molecule/default/playbook.yml b/roles/create_backups/molecule/default/playbook.yml new file mode 100644 index 0000000..c57f038 --- /dev/null +++ b/roles/create_backups/molecule/default/playbook.yml @@ -0,0 +1,6 @@ +--- +- name: Converge + hosts: all + tasks: + - name: Install distro-specific backup support packages + include_tasks: "../../tasks/{{ ansible_distribution|lower }}.yml" diff --git a/roles/create_backups/molecule/default/tests/test_default.py b/roles/create_backups/molecule/default/tests/test_default.py new file mode 100644 index 0000000..4b2be48 --- /dev/null +++ b/roles/create_backups/molecule/default/tests/test_default.py @@ -0,0 +1,10 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_slingshot_installed(host): + assert host.file('/usr/bin/atlassian-slingshot').exists diff --git a/roles/create_backups/tasks/amazon.yml b/roles/create_backups/tasks/amazon.yml new file mode 100644 index 0000000..d9a5e6d --- /dev/null +++ b/roles/create_backups/tasks/amazon.yml @@ -0,0 +1,14 @@ +--- + +- name: Add atlassian-slingshot yum repository + yum_repository: + name: AtlassianSlingshot + file: atlassian-slingshot + state: present + description: Atlassian Slingshot + baseurl: https://packages.atlassian.com/atlassian-slingshot-rpm + gpgcheck: no + +- name: Install atlassian-slingshot + yum: + name: atlassian-slingshot \ No newline at end of file