Skip to content

Commit

Permalink
Merge pull request #41 from systemli/patch-1
Browse files Browse the repository at this point in the history
Bump Integration Workflow to v1.0.0
  • Loading branch information
0x46616c6b authored May 11, 2023
2 parents 5262d96 + 02552cd commit 84a4dcb
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 229 deletions.
7 changes: 3 additions & 4 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
skip_list:
- command-instead-of-module
- fqcn-builtins
- no-handler
exclude_paths:
- molecule/
- .github/
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ on:
jobs:
integration:
name: Integration
uses: systemli/github-ansible-workflow/.github/workflows/ansible-integration-workflow.yaml@main
uses: systemli/github-ansible-workflow/.github/workflows/ansible-integration-workflow.yaml@v1.0.0
with:
distros: '[ "debian11", "debian10" ]'
11 changes: 8 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---

- name: restart schleuder-api-daemon
service:
- name: Restart schleuder-api-daemon
ansible.builtin.systemd:
name: schleuder-api-daemon
state: restarted

- name: Restart schleuder-web
ansible.builtin.systemd:
name: schleuder-web
state: restarted
daemon_reload: true
1 change: 0 additions & 1 deletion requirements.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---

collections:
- community.general
6 changes: 3 additions & 3 deletions tasks/goss.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
- name: Check if goss test directory exists
stat:
ansible.builtin.stat:
path: "{{ goss_test_directory }}"
when: goss_test_directory is defined
register: dir

- name: Copy goss tests
template:
ansible.builtin.template:
src: "test_{{ item }}.yml.j2"
dest: "{{ goss_test_directory }}/test_{{ item }}.yml"
mode: 0644
mode: "0644"
when: dir.stat is defined and dir.stat.exists and dir.stat.isdir
with_items:
- schleuder
30 changes: 14 additions & 16 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
---

- name: Install apt dependencies
apt:
name: "{{ __apt_dependencies }}"
state: 'present'
vars:
__apt_dependencies:
- python{{'3' if ansible_python.version.major == 3 else ''}}-apt
ansible.builtin.apt:
name: "{{ item }}"
state: "present"
loop:
- python{{ '3' if ansible_python.version.major == 3 else '' }}-apt
when:
- ansible_distribution_release == "buster"

- name: Import schleuder tasks
import_tasks: schleuder.yml
ansible.builtin.import_tasks: schleuder.yml
tags:
- schleuder

- name: Import schleuder-cli tasks
import_tasks: schleuder_cli.yml
ansible.builtin.import_tasks: schleuder_cli.yml
tags:
- schleuder_cli
when: schleuder_install_cli

- name: Flush handlers to ensure api is setup correct
meta: flush_handlers
ansible.builtin.meta: flush_handlers

- name: Wait until api is restarted on fresh install
wait_for:
ansible.builtin.wait_for:
port: 4443
delay: 10
when: schleuder_install.changed
when: schleuder_install.changed # noqa: no-handler

- name: Import schleuder web tasks
import_tasks: schleuder_web.yml
ansible.builtin.import_tasks: schleuder_web.yml
tags:
- schleuder_web
when: schleuder_install_web

- name: Import tasks for schleuder Gitlab plugin
import_tasks: schleuder_gitlab_ticket_plugin.yml
ansible.builtin.import_tasks: schleuder_gitlab_ticket_plugin.yml
tags:
- schleuder_gitlab_ticket_plugin
when: schleuder_install_gitlab_ticket_plugin

- name: Include schleuder list tasks per list
include_tasks: schleuder_lists.yml
ansible.builtin.include_tasks: schleuder_lists.yml
with_items: "{{ schleuder_lists }}"
loop_control:
loop_var: list
tags:
- schleuder_lists

- name: Import goss tasks
import_tasks: goss.yml
ansible.builtin.import_tasks: goss.yml
tags:
- schleuder
- goss
96 changes: 48 additions & 48 deletions tasks/schleuder.yml
Original file line number Diff line number Diff line change
@@ -1,125 +1,125 @@
---

- name: install schleuder dependencies
apt:
- name: Install schleuder dependencies
ansible.builtin.apt:
name: "{{ __schleuder_dependencies }}"
state: 'present'
state: "present"
vars:
__schleuder_dependencies:
- sqlite3

- name: install tor
apt:
- name: Install tor
ansible.builtin.apt:
name: tor
state: 'present'
state: "present"
when: schleuder_gpg_use_tor

- name: install schleuder
apt:
- name: Install schleuder
ansible.builtin.apt:
name: "{{ __schleuder_packages }}"
state: 'present'
state: "present"
vars:
__schleuder_packages:
- schleuder
register: schleuder_install

- name: register schleuder tls fingerprint
- name: Register schleuder tls fingerprint
become: true
become_user: "{{ schleuder_schleuder_user }}"
command: /usr/bin/schleuder cert fingerprint
ansible.builtin.command: /usr/bin/schleuder cert fingerprint
register: schleuder_tls_fingerprint_tmp
changed_when: False
check_mode: no
vars:
ansible_ssh_pipelining: True

- name: sanitize schleuder_tls_fingerprint_tmp
set_fact:
- name: Sanitize schleuder_tls_fingerprint_tmp
ansible.builtin.set_fact:
schleuder_tls_fingerprint: "{{ schleuder_tls_fingerprint_tmp.stdout.split(' ')[-1] }}"

- name: generate new schleuder api key (when it does already exists)
- name: Generate new schleuder api key (when it does already exists)
ansible.builtin.command: /usr/bin/schleuder new_api_key
changed_when: false
check_mode: no
become: true
become_user: "{{ schleuder_schleuder_user }}"
command: /usr/bin/schleuder new_api_key
register: schleuder_cli_install_api_key
check_mode: no
when: schleuder_install.changed
when: schleuder_install.changed # noqa: no-handler
vars:
ansible_ssh_pipelining: True

- name: set schleuder_api_key to registered key, if schleuder is installed
set_fact:
- name: Set schleuder_api_key to registered key, if schleuder is installed
ansible.builtin.set_fact:
schleuder_cli_api_key: "{{ schleuder_cli_install_api_key.stdout }}"
when: schleuder_install.changed
when: schleuder_install.changed # noqa: no-handler

# check if API Key already exists
- name: check if schleuder-cli.yml already exists
stat:
- name: Check if schleuder-cli.yml already exists
ansible.builtin.stat:
path: "{{ schleuder_cli_path }}/schleuder-cli.yml"
register: stat_schleuder_cli_path

- name: register existing schleuder api key
shell: "executable=/bin/bash set -o pipefail && grep api_key {{ schleuder_cli_path }}/schleuder-cli.yml | cut -d' ' -f2"
- name: Register existing schleuder api key # noqa: no-free-form
ansible.builtin.shell: "executable=/bin/bash set -o pipefail && grep api_key {{ schleuder_cli_path }}/schleuder-cli.yml | cut -d' ' -f2"
register: schleuder_cli_existing_api_key
check_mode: no
changed_when: False
when: stat_schleuder_cli_path.stat.exists and not schleuder_install.changed

- name: set schleuder_api_key, if schleuder is already installed
set_fact:
- name: Set schleuder_api_key, if schleuder is already installed
ansible.builtin.set_fact:
schleuder_cli_api_key: "{{ schleuder_cli_existing_api_key.stdout }}"
when: stat_schleuder_cli_path.stat.exists and not schleuder_install.changed

- name: ensure schleuder.yml is latest
template:
- name: Ensure schleuder.yml is latest
ansible.builtin.template:
src: schleuder/schleuder.yml.j2
dest: '/etc/schleuder/schleuder.yml'
dest: "/etc/schleuder/schleuder.yml"
owner: "root"
group: "{{ schleuder_schleuder_user }}"
mode: 0640
notify: restart schleuder-api-daemon
mode: "0640"
notify: Restart schleuder-api-daemon

- name: ensure list-defaults.yml is latest
template:
- name: Ensure list-defaults.yml is latest
ansible.builtin.template:
src: schleuder/list-defaults.yml.j2
dest: "/etc/schleuder/list-defaults.yml"
owner: "root"
group: "{{ schleuder_schleuder_user }}"
mode: 0640
mode: "0640"

- name: check if schleuder api is reachable
uri:
- name: Check if schleuder api is reachable
ansible.builtin.uri:
url: "https://{{ schleuder_api.host }}:{{ schleuder_api.port }}/status.json"
validate_certs: False
method: GET
status_code: 200
body_format: json
when:
- schleuder_install.changed
- schleuder_install.changed # noqa: no-handler
- not __testing | default(False)

- name: ensure /var/lib/schleuder/adminkeys is present
file:
- name: Ensure /var/lib/schleuder/adminkeys is present
ansible.builtin.file:
path: "{{ schleuder_admin_keys_path }}"
state: directory
owner: "root"
group: "{{ schleuder_schleuder_user }}"
mode: 0640
mode: "0640"

- name: ensure /var/lib/schleuder/.gnupg is present
file:
- name: Ensure /var/lib/schleuder/.gnupg is present
ansible.builtin.file:
path: "/var/lib/schleuder/.gnupg"
state: directory
owner: "{{ schleuder_schleuder_user }}"
group: "{{ schleuder_schleuder_user }}"
mode: 0700
mode: "0700"
when: schleuder_gpg_use_tor

- name: ensure dirmngr.conf is latest
template:
- name: Ensure dirmngr.conf is latest
ansible.builtin.template:
src: schleuder/dirmngr.conf.j2
dest: '/var/lib/schleuder/.gnupg/dirmngr.conf'
dest: "/var/lib/schleuder/.gnupg/dirmngr.conf"
owner: "{{ schleuder_schleuder_user }}"
group: "{{ schleuder_schleuder_user }}"
mode: 0600
mode: "0600"
when: schleuder_gpg_use_tor
21 changes: 10 additions & 11 deletions tasks/schleuder_cli.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
---

- name: install schleuder-cli
apt:
- name: Install schleuder-cli
ansible.builtin.apt:
name: schleuder-cli
state: 'present'
state: "present"

- name: ensure /root/.schleuder-cli/ is present
file:
- name: Ensure /root/.schleuder-cli/ is present
ansible.builtin.file:
path: "{{ schleuder_cli_path }}"
state: directory
owner: "root"
group: "{{ schleuder_schleuder_user }}"
mode: 0600
mode: "0600"

- name: ensure schleuder-cli.yml is latest
template:
- name: Ensure schleuder-cli.yml is latest
ansible.builtin.template:
src: schleuder-cli/schleuder-cli.yml.j2
dest: "{{ schleuder_cli_path }}/schleuder-cli.yml"
owner: "root"
group: "root"
mode: 0600
notify: restart schleuder-api-daemon
mode: "0600"
notify: Restart schleuder-api-daemon
Loading

0 comments on commit 84a4dcb

Please sign in to comment.