mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-14 00:43:06 -06:00
DCD-224: Fetch the product 'latest' file when no version is specified.
This commit is contained in:
11
roles/jira_download/.yamllint
Normal file
11
roles/jira_download/.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/jira_download/defaults/main.yml
Normal file
5
roles/jira_download/defaults/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
atl_release_base_url: "https://s3.amazonaws.com/atlassian-software/releases"
|
||||
atl_product_latest_version_url: "{{ atl_release_base_url }}/{{ atl_product_edition }}/latest"
|
||||
atl_product_version_cache: "{{ atl_product_home_shared }}/{{ atl_product_edition }}.version"
|
||||
14
roles/jira_download/molecule/default/Dockerfile.j2
Normal file
14
roles/jira_download/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
|
||||
18
roles/jira_download/molecule/default/molecule.yml
Normal file
18
roles/jira_download/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
lint:
|
||||
name: yamllint
|
||||
platforms:
|
||||
- name: instance
|
||||
image: centos:7
|
||||
provisioner:
|
||||
name: ansible
|
||||
lint:
|
||||
name: ansible-lint
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
5
roles/jira_download/molecule/default/playbook.yml
Normal file
5
roles/jira_download/molecule/default/playbook.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: jira_download
|
||||
14
roles/jira_download/molecule/default/tests/test_default.py
Normal file
14
roles/jira_download/molecule/default/tests/test_default.py
Normal file
@@ -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_hosts_file(host):
|
||||
f = host.file('/etc/hosts')
|
||||
|
||||
assert f.exists
|
||||
assert f.user == 'root'
|
||||
assert f.group == 'root'
|
||||
14
roles/jira_download/molecule/version_undefined/Dockerfile.j2
Normal file
14
roles/jira_download/molecule/version_undefined/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
|
||||
23
roles/jira_download/molecule/version_undefined/molecule.yml
Normal file
23
roles/jira_download/molecule/version_undefined/molecule.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
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
|
||||
inventory:
|
||||
links:
|
||||
group_vars: ../../../../group_vars/
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
10
roles/jira_download/molecule/version_undefined/playbook.yml
Normal file
10
roles/jira_download/molecule/version_undefined/playbook.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
vars:
|
||||
atl_product_family: "jira"
|
||||
atl_product_edition: "jira-software"
|
||||
atl_product_user: "jira"
|
||||
roles:
|
||||
- role: product_common
|
||||
- role: jira_download
|
||||
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
import urllib.request
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
|
||||
def test_version_downloaded(host):
|
||||
verfile = host.file('/media/atl/jira/shared/jira-software.version')
|
||||
assert verfile.exists
|
||||
|
||||
def test_version_is_latest(host):
|
||||
verfile = host.file('/media/atl/jira/shared/jira-software.version')
|
||||
assert verfile.exists
|
||||
|
||||
upstream_fd = urllib.request.urlopen("https://s3.amazonaws.com/atlassian-software/releases/jira-software/latest")
|
||||
upstream = upstream_fd.read()
|
||||
|
||||
assert verfile.content.decode("UTF-8").strip() == upstream.decode("UTF-8").strip()
|
||||
9
roles/jira_download/tasks/main.yml
Normal file
9
roles/jira_download/tasks/main.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- name: Fetch the latest version if necessary
|
||||
get_url:
|
||||
url: "{{ atl_product_latest_version_url }}"
|
||||
dest: "{{ atl_product_version_cache }}"
|
||||
force: false
|
||||
when: atl_product_version is undefined or atl_product_version == "latest"
|
||||
|
||||
Reference in New Issue
Block a user