mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-14 00:43:06 -06:00
DCD-386: Rework product_startup to support more systemd params and add tests for some corner cases.
This commit is contained in:
@@ -1,8 +1,17 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
# Mostly for molecule testing, as skip-tags doesn't work with handlers.
|
||||||
|
atl_startup_enable: true
|
||||||
|
atl_startup_restart: true
|
||||||
|
|
||||||
atl_startup_script_map:
|
atl_startup_script_map:
|
||||||
jira: "start-jira.sh"
|
jira: "start-jira.sh"
|
||||||
confluence: "start-confluence.sh"
|
confluence: "start-confluence.sh"
|
||||||
stash: "start-bitbucket.sh"
|
stash: "start-bitbucket.sh"
|
||||||
|
|
||||||
|
atl_startup_exec_path: "{{ atl_product_installation_current }}/bin/{{ atl_startup_script_map[atl_product_family] }}"
|
||||||
|
atl_startup_exec_options: ["-fg"]
|
||||||
|
atl_startup_systemd_params: []
|
||||||
|
|
||||||
|
|
||||||
atl_systemd_service_name: "{{ atl_product_edition }}.service"
|
atl_systemd_service_name: "{{ atl_product_edition }}.service"
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
service:
|
service:
|
||||||
name: "{{ atl_systemd_service_name }}"
|
name: "{{ atl_systemd_service_name }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
|
when: atl_startup_restart
|
||||||
|
|
||||||
- name: Enable Product
|
- name: Enable Product
|
||||||
command: systemctl enable "{{ atl_systemd_service_name }}"
|
command: systemctl enable "{{ atl_systemd_service_name }}"
|
||||||
|
when: atl_startup_enable
|
||||||
|
|
||||||
|
|||||||
14
roles/product_startup/molecule/bitbucket/Dockerfile.j2
Normal file
14
roles/product_startup/molecule/bitbucket/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
|
||||||
36
roles/product_startup/molecule/bitbucket/molecule.yml
Normal file
36
roles/product_startup/molecule/bitbucket/molecule.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
platforms:
|
||||||
|
- name: amazon_linux2
|
||||||
|
image: amazonlinux:2
|
||||||
|
groups:
|
||||||
|
- aws_node_local
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: ubuntu_lts
|
||||||
|
image: ubuntu:bionic
|
||||||
|
groups:
|
||||||
|
- aws_node_local
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
skip-tags: runtime_pkg
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
options:
|
||||||
|
x: ["701"]
|
||||||
|
inventory:
|
||||||
|
links:
|
||||||
|
group_vars: ../../../../group_vars/
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
||||||
|
enabled: false
|
||||||
28
roles/product_startup/molecule/bitbucket/playbook.yml
Normal file
28
roles/product_startup/molecule/bitbucket/playbook.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
atl_product_user: "bitbucket"
|
||||||
|
atl_product_family: "stash"
|
||||||
|
atl_product_edition: "bitbucket"
|
||||||
|
|
||||||
|
atl_startup_systemd_params:
|
||||||
|
- "UMask=0027"
|
||||||
|
- "LimitNOFILE=4096"
|
||||||
|
- "Environment=BITBUCKET_HOME={{ atl_product_home_shared }}"
|
||||||
|
|
||||||
|
atl_startup_exec_options:
|
||||||
|
- "-fg"
|
||||||
|
- "--no-search"
|
||||||
|
|
||||||
|
atl_startup_enable: false
|
||||||
|
atl_startup_restart: false
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Create systemd dir if necessary
|
||||||
|
file:
|
||||||
|
path: '/etc/systemd/system/'
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: product_startup
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
|
||||||
|
|
||||||
|
def test_service_file(host):
|
||||||
|
f = host.file('/etc/systemd/system/bitbucket.service')
|
||||||
|
assert f.contains("^ExecStart=/opt/atlassian/bitbucket/current/bin/start-bitbucket.sh -fg --no-search$")
|
||||||
|
assert f.contains("^UMask=0027$")
|
||||||
|
assert f.contains("^LimitNOFILE=4096$")
|
||||||
|
assert f.contains("^Environment=BITBUCKET_HOME=/media/atl/bitbucket/shared$")
|
||||||
14
roles/product_startup/molecule/default/Dockerfile.j2
Normal file
14
roles/product_startup/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
|
||||||
36
roles/product_startup/molecule/default/molecule.yml
Normal file
36
roles/product_startup/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
platforms:
|
||||||
|
- name: amazon_linux2
|
||||||
|
image: amazonlinux:2
|
||||||
|
groups:
|
||||||
|
- aws_node_local
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: ubuntu_lts
|
||||||
|
image: ubuntu:bionic
|
||||||
|
groups:
|
||||||
|
- aws_node_local
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
skip-tags: runtime_pkg
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
options:
|
||||||
|
x: ["701"]
|
||||||
|
inventory:
|
||||||
|
links:
|
||||||
|
group_vars: ../../../../group_vars/
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
||||||
|
enabled: false
|
||||||
19
roles/product_startup/molecule/default/playbook.yml
Normal file
19
roles/product_startup/molecule/default/playbook.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
atl_product_user: "jira"
|
||||||
|
atl_product_family: "jira"
|
||||||
|
atl_product_edition: "jira-software"
|
||||||
|
|
||||||
|
atl_startup_enable: false
|
||||||
|
atl_startup_restart: false
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Create systemd dir if necessary
|
||||||
|
file:
|
||||||
|
path: '/etc/systemd/system/'
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: product_startup
|
||||||
11
roles/product_startup/molecule/default/tests/test_default.py
Normal file
11
roles/product_startup/molecule/default/tests/test_default.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
|
||||||
|
|
||||||
|
def test_service_file(host):
|
||||||
|
f = host.file('/etc/systemd/system/jira-software.service')
|
||||||
|
assert f.contains("^ExecStart=/opt/atlassian/jira-software/current/bin/start-jira.sh -fg$")
|
||||||
14
roles/product_startup/molecule/synchrony/Dockerfile.j2
Normal file
14
roles/product_startup/molecule/synchrony/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
|
||||||
36
roles/product_startup/molecule/synchrony/molecule.yml
Normal file
36
roles/product_startup/molecule/synchrony/molecule.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
platforms:
|
||||||
|
- name: amazon_linux2
|
||||||
|
image: amazonlinux:2
|
||||||
|
groups:
|
||||||
|
- aws_node_local
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: ubuntu_lts
|
||||||
|
image: ubuntu:bionic
|
||||||
|
groups:
|
||||||
|
- aws_node_local
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
skip-tags: runtime_pkg
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
options:
|
||||||
|
x: ["701"]
|
||||||
|
inventory:
|
||||||
|
links:
|
||||||
|
group_vars: ../../../../group_vars/
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
||||||
|
enabled: false
|
||||||
27
roles/product_startup/molecule/synchrony/playbook.yml
Normal file
27
roles/product_startup/molecule/synchrony/playbook.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
atl_product_user: "confluence"
|
||||||
|
atl_product_family: "confluence"
|
||||||
|
atl_product_edition: "confluence"
|
||||||
|
|
||||||
|
atl_startup_systemd_params:
|
||||||
|
- "EnvironmentFile=/etc/atl"
|
||||||
|
- "EnvironmentFile=/etc/atl.synchrony"
|
||||||
|
- "WorkingDirectory={{ atl_product_installation_current }}/logs/"
|
||||||
|
atl_startup_exec_options: []
|
||||||
|
atl_startup_exec_path: "{{ atl_installation_base }}/bin/start-synchrony"
|
||||||
|
atl_systemd_service_name: "synchrony.service"
|
||||||
|
|
||||||
|
atl_startup_enable: false
|
||||||
|
atl_startup_restart: false
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Create systemd dir if necessary
|
||||||
|
file:
|
||||||
|
path: '/etc/systemd/system/'
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: product_startup
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
|
||||||
|
|
||||||
|
def test_service_file(host):
|
||||||
|
f = host.file('/etc/systemd/system/synchrony.service')
|
||||||
|
assert f.contains("^ExecStart=/opt/atlassian/bin/start-synchrony$")
|
||||||
|
assert f.contains("^EnvironmentFile=/etc/atl$")
|
||||||
|
assert f.contains("^EnvironmentFile=/etc/atl.synchrony$")
|
||||||
|
assert f.contains("^WorkingDirectory=/opt/atlassian/confluence/current/logs/$")
|
||||||
@@ -6,7 +6,12 @@ After=network-online.target
|
|||||||
User={{ atl_product_user }}
|
User={{ atl_product_user }}
|
||||||
Group={{ atl_product_user }}
|
Group={{ atl_product_user }}
|
||||||
|
|
||||||
ExecStart={{ atl_product_installation_current }}/bin/{{ atl_startup_script_map[atl_product_family] }} -fg
|
{% for p in atl_startup_systemd_params -%}
|
||||||
|
{{ p }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
ExecStart={{ atl_startup_exec_path }}{% for c in atl_startup_exec_options %} {{ c }}{% endfor %}
|
||||||
|
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|||||||
Reference in New Issue
Block a user