mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-13 16:33:08 -06:00
DCD-224: Rename product_base to product_common for consistency.
This commit is contained in:
11
roles/product_common/.yamllint
Normal file
11
roles/product_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
|
||||
5
roles/product_common/defaults/main.yml
Normal file
5
roles/product_common/defaults/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
java_version: "1.8.0"
|
||||
java_major_version: "8"
|
||||
postgres_version: "9.6"
|
||||
git_version: "2.14.4"
|
||||
14
roles/product_common/molecule/default/Dockerfile.j2
Normal file
14
roles/product_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/product_common/molecule/default/molecule.yml
Normal file
20
roles/product_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
|
||||
10
roles/product_common/molecule/default/playbook.yml
Normal file
10
roles/product_common/molecule/default/playbook.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
vars:
|
||||
atl_product_user: "testuser"
|
||||
atl_product_home: "/opt/atlassian/product"
|
||||
atl_installer_temp: "/opt/atlassian/temp"
|
||||
roles:
|
||||
- role: linux_common
|
||||
- role: product_common
|
||||
32
roles/product_common/molecule/default/tests/test_default.py
Normal file
32
roles/product_common/molecule/default/tests/test_default.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
import pytest
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
|
||||
def test_user_created(host):
|
||||
user = host.user('testuser')
|
||||
assert user.exists
|
||||
|
||||
|
||||
@pytest.mark.parametrize('target', [
|
||||
'/opt/atlassian/product',
|
||||
'/opt/atlassian/temp'
|
||||
])
|
||||
def test_dirs_created(host, target):
|
||||
d = host.file(target)
|
||||
assert d.exists
|
||||
assert d.is_directory
|
||||
assert d.user == 'testuser'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('exe', [
|
||||
'/usr/bin/git',
|
||||
'/usr/bin/psql',
|
||||
'/usr/bin/javac'
|
||||
])
|
||||
def test_package_exes(host, exe):
|
||||
assert host.file(exe).exists
|
||||
8
roles/product_common/tasks/amazon.yml
Normal file
8
roles/product_common/tasks/amazon.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
- name: Install Java and other base packages on Amazon Linux
|
||||
yum:
|
||||
name:
|
||||
- java-{{ java_version }}-openjdk-devel
|
||||
- git-{{ git_version }}
|
||||
- postgresql
|
||||
19
roles/product_common/tasks/main.yml
Normal file
19
roles/product_common/tasks/main.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
|
||||
- name: Perform distro-specific tasks
|
||||
include: "{{ ansible_distribution|lower }}.yml"
|
||||
|
||||
- name: Create product user
|
||||
user:
|
||||
name: "{{ atl_product_user }}"
|
||||
comment: "Product runtime user"
|
||||
|
||||
- name: Create installation directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ atl_product_user }}"
|
||||
with_items:
|
||||
- "{{ atl_product_home }}"
|
||||
- "{{ atl_installer_temp }}"
|
||||
8
roles/product_common/tasks/ubuntu.yml
Normal file
8
roles/product_common/tasks/ubuntu.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
- name: Install Java and other base packages on Ubuntu
|
||||
package:
|
||||
name:
|
||||
- openjdk-{{ java_major_version }}-jdk-headless
|
||||
- postgresql-client
|
||||
- git
|
||||
Reference in New Issue
Block a user