Skip to content

Commit

Permalink
improv: update variables and common role style (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
antmelekhin committed Jun 6, 2024
1 parent 6395b25 commit 40956b1
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 91 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@ name: 'Molecule'
on:
pull_request:
push:
branches:
- main
branches: ['main']

jobs:
lint:
name: 'Lint'
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'

- name: 'Set up Python 3'
uses: actions/setup-python@v5
uses: 'actions/setup-python@v5'
with:
python-version: '3.x'

- name: 'Install linters'
run: pip3 install ansible-lint yamllint
run: pip3 install ansible-core==2.16.7 ansible-lint==24.5.0 yamllint==1.35.1

- name: 'Run linters'
run: |
Expand All @@ -29,23 +28,26 @@ jobs:
molecule:
name: 'Molecule'
needs: lint
runs-on: ubuntu-latest
needs: 'lint'
runs-on: 'ubuntu-latest'
strategy:
matrix:
include:
- distro: 'debian-11'
- distro: 'debian-12'
- distro: 'rockylinux-8'
- distro: 'rockylinux-9'
- distro: 'ubuntu-20.04'
- distro: 'ubuntu-22.04'

steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'

- name: 'Testing an Ansible role with Molecule'
uses: gofrolist/molecule-action@v2
uses: 'gofrolist/molecule-action@v2'
with:
molecule_command: test
molecule_command: 'test'
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
name: 'Publish'
on:
release:
types:
- published
types: ['published']

jobs:
publish:
name: 'Publish'
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'

- name: 'Set up Python 3'
uses: actions/setup-python@v5
uses: 'actions/setup-python@v5'
with:
python-version: '3.x'

- name: 'Install ansible-core package'
run: pip3 install ansible-core

- name: 'Get an Ansible role name'
id: get_role_name
id: 'get_role_name'
run: echo "ROLE_NAME=$(yq '.galaxy_info.role_name' meta/main.yml)" >> $GITHUB_OUTPUT

- name: 'Publish the role to the Ansible Galaxy'
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ name: 'Release'
on:
workflow_run:
workflows: ['Molecule']
types: [completed]
branches:
- main
types: ['completed']
branches: ['main']

jobs:
release:
name: 'Release'
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
if: ${{ github.repository_owner == 'antmelekhin' && github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'
with:
fetch-depth: 0
persist-credentials: false

- name: 'Semantic Release'
uses: cycjimmy/semantic-release-action@v4
uses: 'cycjimmy/semantic-release-action@v4'
with:
semantic_version: 23.0.8
semantic_version: '23.0.8'
extra_plugins: |
@semantic-release/git@10.0.1
@semantic-release/changelog@6.0.3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
jobs:
update-version:
name: 'Update version'
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
permissions:
contents: write
pull-requests: write
contents: 'write'
pull-requests: 'write'
steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'

- name: 'Update version'
run: .github/scripts/update-version.sh
Expand Down
30 changes: 8 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,12 @@ Requirements
Role Variables
--------------

Variables used to install Jira:

- `jira_product` Jira product.

Available values:
- `software` (default)
- `core`

- `jira_product` Jira product. Available values are: `software` (default), `core`.
- `jira_version` The version of Jira to download (default: `9.12.8`).
- `jira_archive_name` Jira archive name (default: `atlassian-jira-software-9.12.8.tar.gz`).
- `jira_download_url` URL to download the Jira archive (default: `https://www.atlassian.com/software/jira/downloads/binary`).

Variables used to configure Jira:

- `jira_user` and `jira_group` Unix user and group that will be created (default: `jira`).
- `jira_download_path` Local path to download and extract the archive (default: `/tmp`).
- `jira_user` and `jira_group` System user and group that will be created (default: `jira`).
- `jira_root_path` The Jira installation directory (default: `/opt/atlassian/jira`).
- `jira_home_path` The Jira home directory (default: `/var/atlassian/application-data/jira`).
- `jira_min_nofiles_limit` If the limit of files that Jira can open is too low, it will be set to this value (default: `16384`).
Expand All @@ -48,17 +39,12 @@ Variables used to configure Jira:
- `jira_jvm_initial_code_cache_size` and `jira_jvm_reserved_code_cache_size` The size of JVM code cache (default: `32m` and `512m`). A high value of reserved size allows Jira to work with more installed apps.
- `jira_jvm_required_args` The following are the required arguments for Jira.
- `jira_db_configuration` DB connection configuration (default: `false`).
- `jira_db_address` IP address or DNS name of DB server.
- `jira_db_port` DB port.
- `jira_db_address` Hostname or IP address of your database server.
- `jira_db_port` TCP port number for your database server.
- `jira_db_name` DB name.
- `jira_db_username` DB username.
- `jira_db_password` DB password.
- `jira_db_username` and `jira_db_password` Database username and password to be passed to the JDBC driver.
- `jira_catalina_connector_proxyname` Fqdn server name. If you don't use a reverse proxy, then you'll need to leave this variable without value.
- `jira_catalina_connector_scheme` Connection scheme.

Available values:
- `http` (default)
- `https`
- `jira_catalina_connector_scheme` Connection scheme. Available values are: `http` (default), `https`.

**Attention** If you use `https` value, you'll need to install SSL sertificate on server with reverse proxy.

Expand Down Expand Up @@ -108,7 +94,7 @@ roles:
owner: '{{ db_username }}'
- role: antmelekhin.jira
jira_db_configuration: true
jira_db_address: 127.0.0.1
jira_db_host: 127.0.0.1
jira_db_port: 5432
jira_db_name: '{{ db_name }}'
jira_db_username: '{{ db_username }}'
Expand Down
16 changes: 11 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ jira_product: 'software'
jira_version: '9.12.8'
jira_archive_name: 'atlassian-jira-{{ jira_product }}-{{ jira_version }}.tar.gz'
jira_download_url: 'https://www.atlassian.com/software/jira/downloads/binary'
jira_download_path: '/tmp'

# Jira user.
# The Jira user and group
jira_user: 'jira'
jira_group: '{{ jira_user }}'

# Jira directories.
# The Jira directories
jira_root_path: '/opt/atlassian/jira'
jira_home_path: '/var/atlassian/application-data/jira'

# Jira environment configuration.
# The Jira environment configuration
jira_min_nofiles_limit: 16384
jira_jvm_support_recommends_args: ''
jira_jvm_gc_args: '-XX:+ExplicitGCInvokesConcurrent'
Expand All @@ -21,10 +22,15 @@ jira_jvm_maximum_memory: '2048m'
jira_jvm_initial_code_cache_size: '32m'
jira_jvm_reserved_code_cache_size: '512m'

# Jira database connection settings.
# The Jira database connection settings
jira_db_configuration: false
jira_db_host: ''
jira_db_port: ''
jira_db_name: ''
jira_db_username: ''
jira_db_password: ''

# Jira proxy settings.
# The Jira proxy settings
jira_catalina_connector_proxyname: ''
jira_catalina_connector_scheme: 'http'
jira_catalina_connector_proxyport: '{{ (jira_catalina_connector_scheme | lower == "http") | ternary("80", "443") }}'
20 changes: 10 additions & 10 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
---
galaxy_info:
author: antmelekhin
role_name: jira
description: An Ansible role to install, configure and update Jira.
author: 'antmelekhin'
role_name: 'jira'
description: 'An Ansible role to install, configure and update Jira.'

license: MIT
license: 'MIT'

min_ansible_version: '2.9'

platforms:
- name: Debian
- name: 'Debian'
versions:
- 'buster'
- 'bullseye'
- 'bookworm'
- name: EL
- name: 'EL'
versions:
- '7'
- '8'
- '9'
- name: Ubuntu
- name: 'Ubuntu'
versions:
- 'bionic'
- 'focal'
- 'jammy'

galaxy_tags:
- atlassian
- jira
- issuetracker
- 'atlassian'
- 'issuetracker'
- 'jira'

dependencies: []
2 changes: 1 addition & 1 deletion molecule/default/converge-with-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
owner: '{{ db_username }}'
- role: antmelekhin.jira
jira_db_configuration: true
jira_db_address: 127.0.0.1
jira_db_host: 'localhost'
jira_db_port: 5432
jira_db_name: '{{ db_name }}'
jira_db_username: '{{ db_username }}'
Expand Down
18 changes: 9 additions & 9 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
role_name_check: 2
dependency:
name: galaxy
name: 'galaxy'
enabled: true
driver:
name: docker
name: 'docker'
platforms:
- name: 'jira-${IMAGE:-docker-systemd}-${TAG:-ubuntu-22.04}${TOX_ENVNAME}'
image: '${NAMESPACE:-antmelekhin}/${IMAGE:-docker-systemd}:${TAG:-ubuntu-22.04}'
published_ports:
- 0.0.0.0:8080:8080/udp
- 0.0.0.0:8080:8080/tcp
- '0.0.0.0:8080:8080/udp'
- '0.0.0.0:8080:8080/tcp'
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- /var/lib/containerd
cgroupns_mode: host
- '/sys/fs/cgroup:/sys/fs/cgroup:rw'
- '/var/lib/containerd'
cgroupns_mode: 'host'
privileged: true
pre_build_image: true
provisioner:
name: ansible
name: 'ansible'
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
verifier:
name: ansible
name: 'ansible'
12 changes: 6 additions & 6 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
- name: 'Gathering Service Facts'
ansible.builtin.service_facts:

- name: 'Assert that jira service is enabled and running'
- name: 'Assert that Jira service is enabled and running'
ansible.builtin.assert:
that:
- ansible_facts.services['jira.service'].state == 'running'
- ansible_facts.services['jira.service'].status == 'enabled'

- name: 'Check url'
- name: 'Verify the Jira host is responding to requests'
ansible.builtin.uri:
url: 'http://{{ ansible_host }}:8080'
register: __result
until: __result.status == 200
register: __jira_response
until: __jira_response.status == 200
retries: 120
delay: 5

- name: 'Check current Jira version'
- name: 'Check the current Jira version'
ansible.builtin.command:
cmd: grep -Po '(?<=^version=)\N*$' '{{ jira_path }}/atlassian-jira/META-INF/maven/com.atlassian.jira/jira-webapp-dist/pom.properties'
changed_when: false
register: __jira_version_check

- name: 'Version output'
- name: 'Jira version output'
ansible.builtin.debug:
var: __jira_version_check.stdout
2 changes: 1 addition & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: 'Configure and start Jira'
become: true
block:
- name: 'Create a Jira systemd service'
- name: 'Create the Jira systemd service'
ansible.builtin.template:
src: 'jira.service.j2'
dest: '/etc/systemd/system/jira.service'
Expand Down
8 changes: 4 additions & 4 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
- name: 'Download the Jira archive to a local folder'
ansible.builtin.get_url:
url: '{{ jira_download_url }}/{{ jira_archive_name }}'
dest: '/tmp/{{ jira_archive_name }}'
dest: '{{ jira_download_path }}/{{ jira_archive_name }}'
mode: 0644
delegate_to: localhost

- name: 'Unarchive Jira'
ansible.builtin.unarchive:
src: '/tmp/{{ jira_archive_name }}'
src: '{{ jira_download_path }}/{{ jira_archive_name }}'
dest: '{{ _jira_install_path }}'
owner: '{{ jira_user }}'
group: '{{ jira_group }}'
extra_opts:
- --strip-components=1
- '--strip-components=1'
become: true

- name: 'Create a symbolic link to Jira'
- name: 'Create the symbolic link to Jira installation path'
ansible.builtin.file:
src: '{{ _jira_install_path }}'
dest: '{{ _jira_application_path }}'
Expand Down
Loading

0 comments on commit 40956b1

Please sign in to comment.