Files
fedora-infra_ansible/roles/odcs/backend/tasks/main.yml

181 lines
4.0 KiB
YAML

---
- name: Install the httpd package, just to get the apache group on the system.
package:
pkg: httpd
state: present
tags:
- packages
- odcs
- odcs/backend
- name: Make sure Python2 fedmsg-hub isn't running.
service:
name: fedmsg-hub
state: stopped
enabled: false
tags:
- odcs
- odcs/backend
- name: Make sure httpd isn't running.
service:
name: httpd
state: stopped
enabled: false
tags:
- odcs
- odcs/backend
- name: generate the ODCS koji config
template:
src: etc/koji.conf.d/odcs.conf.j2
dest: /etc/koji.conf.d/odcs.conf
owner: odcs
group: fedmsg
mode: 0440
notify:
- restart fedmsg-hub-3
tags:
- odcs
- odcs/backend
- name: add the odcs user to the apache group
user:
name: odcs
group: apache
groups: apache
append: true
notify:
- restart fedmsg-hub-3
tags:
- odcs
- odcs/backend
- name: migrate the database
command: "{{ item }}"
with_items:
- odcs-manager upgradedb
- odcs-manager db migrate
become: yes
become_user: odcs
when: odcs_migrate_db
tags:
- odcs
- odcs/backend
- name: Configure the odcs virtual host
run_once: true
delegate_to: "rabbitmq01{{ env_suffix }}.phx2.fedoraproject.org"
rabbitmq_vhost:
name: /odcs
state: present
tags:
- rabbitmq_cluster
- config
- odcs
- odcs/backend
- name: Configure the HA policy for the odcs queues
run_once: true
delegate_to: "rabbitmq01{{ env_suffix }}.phx2.fedoraproject.org"
rabbitmq_policy:
name: HA
apply_to: queues
pattern: .*
tags:
ha-mode: all
ha-sync-mode: automatic # Auto sync queues to new cluster members
ha-sync-batch-size: 10000 # Larger is faster, but must finish in 1 net_ticktime
vhost: /odcs
tags:
- rabbitmq_cluster
- config
- odcs
- odcs/backend
- name: Add a policy to limit queues to 1GB and remove after a month of no use
run_once: true
delegate_to: "rabbitmq01{{ env_suffix }}.phx2.fedoraproject.org"
rabbitmq_policy:
apply_to: queues
name: pubsub_sweeper
state: present
pattern: ".*"
tags:
# Unused queues are killed after 1000 * 60 * 60 * 31 milliseconds (~a month)
expires: 111600000
# Queues can use at most 1GB of storage
max-length-bytes: 1073741824
vhost: /odcs
tags:
- rabbitmq_cluster
- config
- odcs
- odcs/backend
- name: Create the admin user for the odcs vhost
run_once: true
delegate_to: "rabbitmq01{{ env_suffix }}.phx2.fedoraproject.org"
rabbitmq_user:
user: admin
password: "{{ rabbitmq_odcs_admin_password_staging }}"
permissions:
- vhost: /odcs
configure_priv: .*
read_priv: .*
write_priv: .*
tags: management
when: env == "staging"
tags:
- rabbitmq_cluster
- config
- odcs
- odcs/backend
- name: Create the admin user for the odcs vhost (prod)
run_once: true
delegate_to: "rabbitmq01{{ env_suffix }}.phx2.fedoraproject.org"
rabbitmq_user:
user: admin
password: "{{ rabbitmq_odcs_admin_password_production }}"
permissions:
- vhost: /odcs
configure_priv: .*
read_priv: .*
write_priv: .*
tags: management
when: env != "staging"
tags:
- rabbitmq_cluster
- config
- odcs
- odcs/backend
- name: Dump the admin password in a file for administrative operations
run_once: true
delegate_to: "rabbitmq01{{ env_suffix }}.phx2.fedoraproject.org"
copy:
dest: /root/.odcs-rabbitmqpass
content: "{{ (env == 'production')|ternary(rabbitmq_odcs_admin_password_production, rabbitmq_odcs_admin_password_staging) }}"
mode: 0600
owner: root
group: root
tags:
- rabbitmq_cluster
- config
- odcs
- odcs/backend
# Create a user with:
- name: Create a user for odcs access
run_once: true
delegate_to: "rabbitmq01{{ env_suffix }}.phx2.fedoraproject.org"
rabbitmq_user:
user: "odcs-private-queue{{ env_suffix }}"
permissions:
- vhost: /odcs
configure_priv: .*
write_priv: .*
read_priv: .*
state: present
tags:
- rabbitmq_cluster
- config
- odcs
- odcs/backend