Manage opendev.org cert with LE

This is the first step in managing the opendev.org cert with LE. We
modify gitea01.opendev.org only to request the cert so that if this
breaks the other 7 giteas can continue to serve opendev.org. When we are
happy with the results we can merge the followup change to update the
other 7 giteas.

Depends-On: https://review.opendev.org/694182
Change-Id: I9587b8c2896975aa0148cc3d9b37f325a0be8970
This commit is contained in:
Clark Boylan 2019-11-13 16:33:35 -08:00
parent 7e3ad37e5a
commit 5392f8a27c
9 changed files with 70 additions and 59 deletions

View File

@ -958,6 +958,7 @@
label: ubuntu-bionic label: ubuntu-bionic
vars: vars:
run_playbooks: run_playbooks:
- playbooks/service-letsencrypt.yaml
- playbooks/service-gitea-lb.yaml - playbooks/service-gitea-lb.yaml
- playbooks/remote_puppet_git.yaml - playbooks/remote_puppet_git.yaml
run_test_playbook: playbooks/test-gitea.yaml run_test_playbook: playbooks/test-gitea.yaml
@ -979,6 +980,7 @@
- playbooks/roles/gitea/ - playbooks/roles/gitea/
- playbooks/roles/gitea-git-repos/ - playbooks/roles/gitea-git-repos/
- playbooks/roles/haproxy/ - playbooks/roles/haproxy/
- playbooks/roles/letsencrypt-create-certs/handlers/restart_gitea.yaml
- testinfra/test_gitea.py - testinfra/test_gitea.py
- testinfra/test_gitea_lb.py - testinfra/test_gitea_lb.py
# From gitea_files -- If we rebuild the image, we want to run # From gitea_files -- If we rebuild the image, we want to run

View File

@ -68,6 +68,8 @@ groups:
- mirror[0-9]*.opendev.org - mirror[0-9]*.opendev.org
- files[0-9]*.open*.org - files[0-9]*.open*.org
- static.openstack.org - static.openstack.org
- gitea01.opendev.org
- gitea99.opendev.org
logstash: logstash:
- logstash[0-9]*.open*.org - logstash[0-9]*.open*.org
logstash-worker: logstash-worker:

View File

@ -0,0 +1,4 @@
letsencrypt_certs:
gitea01-main:
- gitea01.opendev.org
- opendev.org

View File

@ -20,14 +20,6 @@
- logs - logs
- certs - certs
- db - db
- name: Write TLS private key
copy:
content: "{{ gitea_tls_key }}"
dest: /var/gitea/certs/key.pem
- name: Write TLS certificate
copy:
content: "{{ gitea_tls_cert }}"
dest: /var/gitea/certs/cert.pem
- name: Write app.ini - name: Write app.ini
template: template:
src: app.ini.j2 src: app.ini.j2

View File

@ -58,3 +58,11 @@
- name: letsencrypt updated mirror01-openafs-provider-opendev-org-main - name: letsencrypt updated mirror01-openafs-provider-opendev-org-main
include_tasks: roles/letsencrypt-create-certs/handlers/restart_apache.yaml include_tasks: roles/letsencrypt-create-certs/handlers/restart_apache.yaml
- name: letsencrypt updated gitea99-main
include_tasks: roles/letsencrypt-create-certs/handlers/restart_gitea.yaml
# We split out handlers for each gitea host as handlers should be run in order
# This allows us to do a rolling restart of the gitea backends.
- name: letsencrypt updated gitea01-main
include_tasks: roles/letsencrypt-create-certs/handlers/restart_gitea.yaml

View File

@ -0,0 +1,49 @@
- name: Ensure gitea cert directy exists
file:
state: directory
path: "/var/gitea/certs"
owner: 1000
group: 1000
- name: Put key in place
copy:
remote_src: yes
src: /etc/letsencrypt-certs/{{ inventory_hostname }}/{{ inventory_hostname }}.key
dest: /var/gitea/certs/key.pem
owner: root
group: root
mode: '0644'
- name: Put cert in place
copy:
remote_src: yes
# Gitea doesn't seem to accept separate ca chain and cert files.
# I believe it wants a single combined file as per fullchain.cer.
src: /etc/letsencrypt-certs/{{ inventory_hostname }}/fullchain.cer
dest: /var/gitea/certs/cert.pem
owner: root
group: root
mode: '0644'
- name: Check for running gitea
command: pgrep -f gitea
ignore_errors: yes
register: gitea_pids
- name: Restart gitea if running
when: gitea_pids.rc == 0
block:
- name: Restart gitea web
shell:
cmd: docker-compose restart gitea-web
chdir: /etc/gitea-docker/
- name: Wait for service to start and have valid users
uri:
url: "https://localhost:3000/api/v1/users/root"
validate_certs: false
status_code: 200, 404
register: root_user_check
delay: 1
retries: 300
until: root_user_check and root_user_check.status in (200, 404)

View File

@ -85,6 +85,7 @@
- host_vars/bridge.openstack.org.yaml - host_vars/bridge.openstack.org.yaml
- host_vars/letsencrypt01.opendev.org.yaml - host_vars/letsencrypt01.opendev.org.yaml
- host_vars/letsencrypt02.opendev.org.yaml - host_vars/letsencrypt02.opendev.org.yaml
- host_vars/gitea99.opendev.org.yaml
- host_vars/mirror01.openafs.provider.opendev.org.yaml - host_vars/mirror01.openafs.provider.opendev.org.yaml
- host_vars/mirror-update01.opendev.org.yaml - host_vars/mirror-update01.opendev.org.yaml
- host_vars/backup-test01.opendev.org.yaml - host_vars/backup-test01.opendev.org.yaml

View File

@ -7,54 +7,3 @@ gitea_db_password: 5bfuOBKtltff0XZX
gitea_root_password: BUbBcpToMwR05ZCB gitea_root_password: BUbBcpToMwR05ZCB
gitea_no_log: false gitea_no_log: false
gitea_gerrit_password: yVpMWIUIvT7f6NwA gitea_gerrit_password: yVpMWIUIvT7f6NwA
gitea_tls_cert: |
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJANOV6XqCusL0MA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwHhcNMTkwMjE1MjIwNjI0WhcNMTkwMzE3MjIwNjI0WjBF
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAvXpjO7ViMSG5IuSi7Y76wGUML2WpVyjGKeJur2BQkQQwy+5daUAwM0sr
sSa31IDya9hlDetQpLFE1QPFrwkNe2MT9+V/vIJJDoRbt2Tgrzj1ZL/DSws1FikF
L7vI8Je0Hb4Ylhd66xeuoz3jQW6ky9huJi8ZEkc4DNa1ehkyZd2nUXsu5DizQEU6
b+I5LneikWPrMSNOMSw3BrC9P6j9X8/j2Txpmkww3sC+TegsQKQSNTBvz8HUM6m6
OlT/yezjkNCDd/HHR49veMiOgvwJK6ZVGXl7Pg/tb+pi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