system-config/playbooks/roles/gerritbot/tasks/main.yaml
Clark Boylan fd88087335 Run gerritbot with a user that will be shared with matrix-gerritbot
They have roughly the same level of access so lets align things.

Change-Id: Ifbe9dae7038345e20e8b498c87a37c519829a8cc
2021-11-05 11:24:05 -07:00

93 lines
2.1 KiB
YAML

- name: Create gerritbot group
group:
name: "gerritbot"
gid: "{{ gerritbot_gid }}"
system: yes
- name: Create gerritbot user
user:
name: "gerritbot"
group: "gerritbot"
uid: "{{ gerritbot_uid }}"
home: "/var/lib/gerritbot"
create_home: yes
shell: /bin/bash
system: yes
- name: Ensure /etc/gerritbot directory
file:
state: directory
path: /etc/gerritbot
owner: gerritbot
group: gerritbot
mode: 0755
- name: Put gerritbot config in place
template:
src: gerritbot.config.j2
dest: /etc/gerritbot/gerritbot.config
owner: gerritbot
group: gerritbot
mode: 0600
- name: Put gerritbot logging config in place
copy:
src: logging.config
dest: /etc/gerritbot/logging.config
owner: gerritbot
group: gerritbot
mode: 0644
- name: Put gerritbot channel config in place
copy:
src: /opt/project-config/gerritbot/channels.yaml
remote_src: yes
dest: /etc/gerritbot/channel_config.yaml
owner: gerritbot
group: gerritbot
mode: 0644
register: channel_config_copied
- name: Put gerritbot ssh key in place
copy:
content: "{{ gerritbot_ssh_key }}"
dest: /etc/gerritbot/gerritbot_rsa
owner: gerritbot
group: gerritbot
mode: 0600
- name: Put gerritbot ssh pubkey in place
copy:
content: "{{ gerritbot_ssh_pubkey }}"
dest: /etc/gerritbot/gerritbot_rsa.pub
owner: gerritbot
group: gerritbot
mode: 0600
- name: Ensure /etc/gerritbot-docker directory
file:
state: directory
path: /etc/gerritbot-docker
mode: 0755
- name: Put docker-compose file in place
template:
src: docker-compose.yaml.j2
dest: /etc/gerritbot-docker/docker-compose.yaml
owner: root
group: root
mode: 0644
- name: Run docker-compose pull
shell:
cmd: docker-compose pull
chdir: /etc/gerritbot-docker/
- name: Run docker-compose up
shell:
cmd: "docker-compose up -d {{ channel_config_copied is changed | ternary('--force-recreate', '') }}"
chdir: /etc/gerritbot-docker/
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f