mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-14 00:43:06 -06:00
DCD-224: New task for common package installs that is cross-distro.
This commit is contained in:
11
roles/linux-common/.yamllint
Normal file
11
roles/linux-common/.yamllint
Normal file
@@ -0,0 +1,11 @@
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
braces:
|
||||
max-spaces-inside: 1
|
||||
level: error
|
||||
brackets:
|
||||
max-spaces-inside: 1
|
||||
level: error
|
||||
line-length: disable
|
||||
truthy: disable
|
||||
14
roles/linux-common/molecule/default/Dockerfile.j2
Normal file
14
roles/linux-common/molecule/default/Dockerfile.j2
Normal file
@@ -0,0 +1,14 @@
|
||||
# Molecule managed
|
||||
|
||||
{% if item.registry is defined %}
|
||||
FROM {{ item.registry.url }}/{{ item.image }}
|
||||
{% else %}
|
||||
FROM {{ item.image }}
|
||||
{% endif %}
|
||||
|
||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
|
||||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && 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 && 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 && xbps-remove -O; fi
|
||||
20
roles/linux-common/molecule/default/molecule.yml
Normal file
20
roles/linux-common/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
lint:
|
||||
name: yamllint
|
||||
platforms:
|
||||
- name: amazon_linux2
|
||||
image: amazonlinux:2
|
||||
- name: ubuntu_lts
|
||||
image: ubuntu:bionic
|
||||
provisioner:
|
||||
name: ansible
|
||||
lint:
|
||||
name: ansible-lint
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
5
roles/linux-common/molecule/default/playbook.yml
Normal file
5
roles/linux-common/molecule/default/playbook.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: linux-common
|
||||
16
roles/linux-common/molecule/default/tests/test_default.py
Normal file
16
roles/linux-common/molecule/default/tests/test_default.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
|
||||
def test_user_prereq(host):
|
||||
f = host.file('/usr/sbin/useradd')
|
||||
assert f.exists
|
||||
|
||||
|
||||
def test_support_packages(host):
|
||||
assert host.file('/usr/bin/jq').exists
|
||||
assert host.file('/usr/bin/curl').exists
|
||||
1
roles/linux-common/tasks/debian.yml
Normal file
1
roles/linux-common/tasks/debian.yml
Normal file
@@ -0,0 +1 @@
|
||||
---
|
||||
12
roles/linux-common/tasks/main.yml
Normal file
12
roles/linux-common/tasks/main.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
|
||||
# Note: Try and limit these to packages that are distro-specific, and
|
||||
# place commonly-named ones below.
|
||||
- name: Install distro-specific prerequisites
|
||||
include: "{{ ansible_os_family|lower }}.yml"
|
||||
|
||||
- name: Install common support packags
|
||||
package:
|
||||
name:
|
||||
- jq
|
||||
- curl
|
||||
6
roles/linux-common/tasks/redhat.yml
Normal file
6
roles/linux-common/tasks/redhat.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
- name: Install Redhat family support packages
|
||||
yum:
|
||||
name:
|
||||
- shadow-utils
|
||||
Reference in New Issue
Block a user