mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-13 08:23:06 -06:00
Merged in ITPLAT-476-cast-atl_startup_restart-to-bool (pull request #129)
ITPLAT-476 cast atl_startup_restart to bool Approved-by: Ben Partridge
This commit is contained in:
@@ -18,7 +18,7 @@ pipelines:
|
||||
- step:
|
||||
name: Pre Parallelization stage
|
||||
script:
|
||||
- echo "Running tests in 37 batches"
|
||||
- echo "Running tests in 38 batches"
|
||||
|
||||
- step:
|
||||
name: Check if the template is up-to-date
|
||||
@@ -97,6 +97,14 @@ pipelines:
|
||||
- ./bin/install-ansible --dev
|
||||
- cd roles/product_startup
|
||||
- pipenv run molecule test -s bitbucket
|
||||
- step:
|
||||
name: product_startup/startup_restart_false
|
||||
services:
|
||||
- docker
|
||||
script:
|
||||
- ./bin/install-ansible --dev
|
||||
- cd roles/product_startup
|
||||
- pipenv run molecule test -s startup_restart_false
|
||||
- step:
|
||||
name: product_common/default
|
||||
services:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Mostly for molecule testing, as skip-tags doesn't work with handlers.
|
||||
atl_startup_enable: true
|
||||
atl_startup_restart: "{{ lookup('env', 'ATL_STARTUP_RESTART') or true }}"
|
||||
atl_startup_restart: "{{ lookup('env', 'ATL_STARTUP_RESTART') | default(true, true) | bool }}"
|
||||
|
||||
atl_startup_script_map:
|
||||
jira: "bin/start-jira.sh"
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
service:
|
||||
name: "{{ atl_systemd_service_name }}"
|
||||
state: restarted
|
||||
when: atl_startup_restart
|
||||
when:
|
||||
- atl_startup_restart
|
||||
- molecule_yml is not defined
|
||||
no_log: true
|
||||
|
||||
- name: Enable Product
|
||||
service:
|
||||
name: "{{ atl_systemd_service_name }}"
|
||||
enabled: true
|
||||
when: atl_startup_enable
|
||||
when:
|
||||
- atl_startup_enable
|
||||
- molecule_yml is not defined
|
||||
no_log: true
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
atl_product_family: "jira"
|
||||
atl_product_edition: "jira-software"
|
||||
|
||||
atl_startup_enable: false
|
||||
atl_startup_restart: false
|
||||
ansible_vars_dump_location: "/tmp/ansible-vars.yml"
|
||||
|
||||
pre_tasks:
|
||||
- name: Create systemd dir if necessary
|
||||
@@ -20,3 +19,20 @@
|
||||
|
||||
roles:
|
||||
- role: product_startup
|
||||
|
||||
post_tasks:
|
||||
- include_vars: ../../defaults/main.yml
|
||||
|
||||
# workaround Molecule idempotence check
|
||||
# normal pattern of setting changed_when allows file to be written twice, which takes extra time
|
||||
- name: Check if vars have already been dumped
|
||||
stat:
|
||||
path: "{{ ansible_vars_dump_location }}"
|
||||
register: ansible_vars_stat_result
|
||||
|
||||
- name: Dump vars to file for inspection
|
||||
copy:
|
||||
content: |
|
||||
{{ vars | to_nice_yaml }}
|
||||
dest: "{{ ansible_vars_dump_location }}"
|
||||
when: not ansible_vars_stat_result.stat.exists
|
||||
|
||||
@@ -13,3 +13,9 @@ def test_service_file(host):
|
||||
assert f.user == 'root'
|
||||
assert f.group == 'root'
|
||||
assert f.mode == 0o0640
|
||||
|
||||
|
||||
def test_atl_startup_restart(host):
|
||||
f = host.file('/tmp/ansible-vars.yml')
|
||||
# value should appear as YAML boolean true (i.e., string 'true' will fail)
|
||||
assert f.contains(r'^\s*atl_startup_restart: true$')
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
vars:
|
||||
atl_product_user: "jira"
|
||||
atl_product_family: "jira"
|
||||
atl_product_edition: "jira-software"
|
||||
atl_startup_enable: false
|
||||
|
||||
ansible_vars_dump_location: "/tmp/ansible-vars.yml"
|
||||
|
||||
tasks:
|
||||
- include_vars: ../../defaults/main.yml
|
||||
|
||||
# workaround Molecule idempotence check
|
||||
# normal pattern of setting changed_when allows file to be written twice, which takes extra time
|
||||
- name: Check if vars have already been dumped
|
||||
stat:
|
||||
path: "{{ ansible_vars_dump_location }}"
|
||||
register: ansible_vars_stat_result
|
||||
|
||||
- name: Dump vars to file for inspection
|
||||
copy:
|
||||
content: |
|
||||
{{ vars | to_nice_yaml }}
|
||||
dest: "{{ ansible_vars_dump_location }}"
|
||||
when: not ansible_vars_stat_result.stat.exists
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
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
|
||||
env:
|
||||
ATL_STARTUP_RESTART: "false"
|
||||
options:
|
||||
skip-tags: runtime_pkg
|
||||
inventory:
|
||||
links:
|
||||
group_vars: ../../../../group_vars/
|
||||
verifier:
|
||||
name: testinfra
|
||||
@@ -0,0 +1,12 @@
|
||||
import os
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
|
||||
def test_atl_startup_restart(host):
|
||||
f = host.file('/tmp/ansible-vars.yml')
|
||||
# value should appear as YAML boolean false (i.e., boolean true or string 'false' will fail)
|
||||
assert f.contains(r'^\s*atl_startup_restart: false$')
|
||||
Reference in New Issue
Block a user