ansible-gerrit-management/tasks/deploy.yml

71 lines
2.0 KiB
YAML
Raw Normal View History

2023-07-25 08:49:15 +00:00
---
- name: Download gerrit
ansible.builtin.get_url:
url: "{{ gerrit_download_url }}"
dest: "{{ gerrit_home_dir }}"
owner: "{{ gerrit_user }}"
group: "{{ gerrit_group }}"
mode: "0644"
- name: Drop gerrit config
ansible.builtin.template:
src: gerrit.config.j2
dest: "{{ gerrit_home_dir }}/{{ gerrit_site }}/etc/gerrit.config"
owner: "{{ gerrit_user }}"
group: "{{ gerrit_group }}"
mode: "0644"
notify: restart_gerrit
register: gerrit_config
- name: Drop secure gerrit config
ansible.builtin.template:
src: secure.config.j2
dest: "{{ gerrit_home_dir }}/{{ gerrit_site }}/etc/secure.config"
owner: "{{ gerrit_user }}"
group: "{{ gerrit_group }}"
mode: "0600"
notify: restart_gerrit
register: gerrit_secure_config
- name: Drop systemd unit
ansible.builtin.template:
src: gerrit.service.j2
dest: /etc/systemd/system/gerrit.service
owner: root
group: root
mode: "0644"
notify: reload_systemd
register: gerrit_systemd
- name: Perform gerrit tasks if configuration has changed
when:
- gerrit_secure_config.changed
- gerrit_config.changed
block:
- name: Stop gerrit
ansible.builtin.systemd:
name: gerrit.service
state: stopped
- name: Re-init gerrit
ansible.builtin.shell: "{{ gerrit_java_path }} -jar gerrit-{{ gerrit_version }}.war init --batch --no-auto-start -d {{ gerrit_home_dir }}/{{ gerrit_site }}"
args:
chdir: "{{ gerrit_home_dir }}"
become: true
become_user: "{{ gerrit_user }}"
changed_when: "1 != 1"
- name: Re-index gerrit
ansible.builtin.shell: "{{ gerrit_java_path }} -jar gerrit-{{ gerrit_version }}.war reindex -d {{ gerrit_home_dir }}/{{ gerrit_site }}"
args:
chdir: "{{ gerrit_home_dir }}"
become: true
become_user: "{{ gerrit_user }}"
changed_when: "1 != 1"
- name: Ensure gerrit is enabled
ansible.builtin.systemd:
name: gerrit.service
enabled: true
...