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
This commit is contained in:
Clark Boylan 2021-11-04 16:33:07 -07:00
parent 698bb3df21
commit fd88087335
4 changed files with 35 additions and 13 deletions

View File

@ -188,3 +188,5 @@ statusbot_auth_nicks:
- clarkb - clarkb
- ianw - ianw
- frickler - frickler
gerritbot_gid: 11000
gerritbot_uid: 11000

View File

@ -1,3 +1,5 @@
gerritbot_gid: 11000
gerritbot_uid: 11000
gerritbot_irc_nick: opendevreview gerritbot_irc_nick: opendevreview
gerritbot_irc_server: irc.oftc.net gerritbot_irc_server: irc.oftc.net
gerritbot_gerrit_user: gerritbot gerritbot_gerrit_user: gerritbot

View File

@ -1,23 +1,40 @@
- 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 - name: Ensure /etc/gerritbot directory
file: file:
state: directory state: directory
path: /etc/gerritbot path: /etc/gerritbot
owner: gerritbot
group: gerritbot
mode: 0755 mode: 0755
- name: Put gerritbot config in place - name: Put gerritbot config in place
template: template:
src: gerritbot.config.j2 src: gerritbot.config.j2
dest: /etc/gerritbot/gerritbot.config dest: /etc/gerritbot/gerritbot.config
owner: root owner: gerritbot
group: root group: gerritbot
mode: 0600 mode: 0600
- name: Put gerritbot logging config in place - name: Put gerritbot logging config in place
copy: copy:
src: logging.config src: logging.config
dest: /etc/gerritbot/logging.config dest: /etc/gerritbot/logging.config
owner: root owner: gerritbot
group: root group: gerritbot
mode: 0644 mode: 0644
- name: Put gerritbot channel config in place - name: Put gerritbot channel config in place
@ -25,8 +42,8 @@
src: /opt/project-config/gerritbot/channels.yaml src: /opt/project-config/gerritbot/channels.yaml
remote_src: yes remote_src: yes
dest: /etc/gerritbot/channel_config.yaml dest: /etc/gerritbot/channel_config.yaml
owner: root owner: gerritbot
group: root group: gerritbot
mode: 0644 mode: 0644
register: channel_config_copied register: channel_config_copied
@ -34,16 +51,16 @@
copy: copy:
content: "{{ gerritbot_ssh_key }}" content: "{{ gerritbot_ssh_key }}"
dest: /etc/gerritbot/gerritbot_rsa dest: /etc/gerritbot/gerritbot_rsa
owner: root owner: gerritbot
group: root group: gerritbot
mode: 0600 mode: 0600
- name: Put gerritbot ssh pubkey in place - name: Put gerritbot ssh pubkey in place
copy: copy:
content: "{{ gerritbot_ssh_pubkey }}" content: "{{ gerritbot_ssh_pubkey }}"
dest: /etc/gerritbot/gerritbot_rsa.pub dest: /etc/gerritbot/gerritbot_rsa.pub
owner: root owner: gerritbot
group: root group: gerritbot
mode: 0600 mode: 0600
- name: Ensure /etc/gerritbot-docker directory - name: Ensure /etc/gerritbot-docker directory
@ -53,8 +70,8 @@
mode: 0755 mode: 0755
- name: Put docker-compose file in place - name: Put docker-compose file in place
copy: template:
src: docker-compose.yaml src: docker-compose.yaml.j2
dest: /etc/gerritbot-docker/docker-compose.yaml dest: /etc/gerritbot-docker/docker-compose.yaml
owner: root owner: root
group: root group: root

View File

@ -6,6 +6,7 @@ services:
gerritbot: gerritbot:
image: docker.io/opendevorg/gerritbot:latest image: docker.io/opendevorg/gerritbot:latest
network_mode: host network_mode: host
user: "{{ gerritbot_uid }}:{{ gerritbot_gid }}"
restart: always restart: always
logging: logging:
driver: syslog driver: syslog
@ -13,4 +14,4 @@ services:
tag: "docker-gerritbot" tag: "docker-gerritbot"
volumes: volumes:
# This contains the main config, channel config, and ssh key # This contains the main config, channel config, and ssh key
- /etc/gerritbot:/etc/gerritbot - /etc/gerritbot:/etc/gerritbot:ro