diff --git a/ansible/playbooks/init-rocky-bugzilla.yml b/ansible/playbooks/init-rocky-bugzilla.yml index ce73147..f5cc2bb 100644 --- a/ansible/playbooks/init-rocky-bugzilla.yml +++ b/ansible/playbooks/init-rocky-bugzilla.yml @@ -3,6 +3,11 @@ - name: Configure MantisBT hosts: "bugtracker" become: true + vars_files: + - vars/common.yml + - vars/vaults/encpass.yml + - vars/vaults/mantis.yml + - vars/mantis.yml handlers: - import_tasks: handlers/main.yml @@ -20,11 +25,31 @@ success_msg: "We are not able to run on this node" fail_msg: "/etc/no-ansible exists - skipping run on this node" + roles: + - role: rockylinux.ipagetcert + state: present + tasks: - name: Deploy Mantis import_tasks: tasks/mantis.yml post_tasks: + - name: Open firewalld ports + ansible.posix.firewalld: + service: "{{ item }}" + permanent: true + immediate: true + state: enabled + with_items: + - http + - https + + - name: Ensure httpd is enabled and running + service: + name: httpd + enabled: true + state: started + - name: Touching run file that ansible has ran here file: path: /var/log/ansible.run diff --git a/ansible/playbooks/tasks/mantis.yml b/ansible/playbooks/tasks/mantis.yml index 4aaa4cf..202b8ff 100644 --- a/ansible/playbooks/tasks/mantis.yml +++ b/ansible/playbooks/tasks/mantis.yml @@ -32,6 +32,11 @@ mode: '0644' remote_src: true +- name: Generate crypto salt + shell: "cat /dev/urandom | head -c 64 | base64 --wrap=0" + changed_when: "1 != 1" + register: cryptosalt_string + - name: Configure mantis template: src: "var/www/mantis/config/config_inc.php.j2" @@ -40,6 +45,22 @@ group: apache mode: '0640' +- name: Deploy plugins from Mantis GitHub + git: + repo: "https://github.com/mantisbt-plugins/{{ item }}.git" + dest: "/var/www/mantisbt-{{ mantis_version }}/plugins/{{ item }}" + update: true + version: master + with_items: + - Snippets + +- name: Deploy custom libravatar plugin + git: + repo: "https://github.com/nazunalika/mantisbt-libravatar.git" + dest: "/var/www/mantisbt-{{ mantis_version }}/plugins/Libravatar" + update: true + version: main + - name: Configure httpd template: src: "etc/httpd/conf.d/mantis.conf.j2" @@ -47,3 +68,25 @@ owner: root group: root mode: '0644' + +- name: Database import template + template: + src: "tmp/mantis_import.sql.j2" + dest: "/tmp/mantis_import.sql.j2" + owner: root + group: root + mode: '0600' + +# We will need to generate this +# name: Import database if required +# community.general.postgresql_db: +# name: "{{ mantis_db_name }}" +# target: /tmp/mantis_import.sql +# owner: "{{ mantis_db_user }}" +# state: restore +# login_host: "{{ mantis_db_host }}" +# login_user: "{{ mantis_db_user }}" +# login_password: "{{ mantis_db_pass }}" + +- name: Patch up some pages + import_tasks: mantispatch.yml diff --git a/ansible/playbooks/tasks/mantispatch.yml b/ansible/playbooks/tasks/mantispatch.yml new file mode 100644 index 0000000..0e4a4b8 --- /dev/null +++ b/ansible/playbooks/tasks/mantispatch.yml @@ -0,0 +1,25 @@ +--- +# Patch up various pieces of mantis to customize it. We do not rely on local +# bug tracker accounts. We are doing regex instead of just replacing the +# file as a whole. Should make it easier to deal with upgrades in theory. +- name: Change signup_page.php to Account Services + replace: + path: "/var/www/mantisbt-{{ mantis_version }}/{{ item }}" + regexp: 'signup_page.php' + replace: 'https://accounts.rockylinux.org' + with_items: + - core/print_api.php + - lost_pwd_page.php + - login_page.php + +- name: Change special signup_page.php reference + replace: + path: "/var/www/mantisbt-{{ mantis_version }}/core/layout_api.php" + regexp: "' . helper_mantis_url( 'signup_page.php' ) . '" + replace: 'https://accounts.rockylinux.org' + +- name: Remove LDAP from checks for signup button + lineinfile: + path: "/var/www/mantisbt-{{ mantis_version }}/login_page.php" + state: absent + regex: 'LDAP != config_get_global' diff --git a/ansible/playbooks/templates/tmp/mantis_import.sql.j2 b/ansible/playbooks/templates/tmp/mantis_import.sql.j2 new file mode 100644 index 0000000..b7db254 --- /dev/null +++ b/ansible/playbooks/templates/tmp/mantis_import.sql.j2 @@ -0,0 +1 @@ +# Empty diff --git a/ansible/playbooks/templates/var/www/mantis/config/config_inc.php.j2 b/ansible/playbooks/templates/var/www/mantis/config/config_inc.php.j2 index ec78437..f224283 100644 --- a/ansible/playbooks/templates/var/www/mantis/config/config_inc.php.j2 +++ b/ansible/playbooks/templates/var/www/mantis/config/config_inc.php.j2 @@ -1,5 +1,5 @@