diff --git a/playbooks/openshift-apps/elnbuildsync.yml b/playbooks/openshift-apps/elnbuildsync.yml index 0181be6706..0cd43aca87 100644 --- a/playbooks/openshift-apps/elnbuildsync.yml +++ b/playbooks/openshift-apps/elnbuildsync.yml @@ -31,25 +31,32 @@ - /srv/private/ansible/vars.yml - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml - pre_tasks: - - name: Set up ELN RabbitMQ queue - ansible.builtin.include_role: - name: rabbit/queue - vars: - queue_username: distrobuildsync-eln - user_sent_topics: ^$ - queue_name: distrobuildsync-eln - # TTL: 10 days (in miliseconds) - queue_message_ttl: 864000000 - queue_routing_keys: - - "#.buildsys.repo.init" - - "#.buildsys.repo.done" - - "#.buildsys.tag" - - "#.buildsys.task.state.change" - - "org.fedoraproject.{{ env_short }}.elnbuildsync.#" - when: env != 'staging' - roles: + - role: rabbit/user + user_name: "elnbuildsync{{ env_suffix }}" + user_sent_topics: ^$ + tags: + - config + - fedora-messaging + - rabbitmq_cluster + + - role: rabbit/queue + queue_username: "elnbuildsync{{ env_suffix }}" + user_sent_topics: ^$ + queue_name: "elnbuildsync{{ env_suffix }}" + # TTL: 10 days (in miliseconds) + queue_message_ttl: 864000000 + queue_routing_keys: + - "#.buildsys.repo.init" + - "#.buildsys.repo.done" + - "#.buildsys.tag" + - "#.buildsys.task.state.change" + - "org.fedoraproject.{{ env_short }}.elnbuildsync.#" + tags: + - config + - fedora-messaging + - rabbitmq_cluster + - role: openshift/project project_app: elnbuildsync project_description: ELNBuildSync is a tool that listens for Fedora Rawhide builds and re-builds them in the Fedora ELN build environment. diff --git a/roles/openshift-apps/elnbuildsync/templates/fedora-messaging-config.toml b/roles/openshift-apps/elnbuildsync/templates/fedora-messaging-config.toml new file mode 100644 index 0000000000..f7838bb07f --- /dev/null +++ b/roles/openshift-apps/elnbuildsync/templates/fedora-messaging-config.toml @@ -0,0 +1,97 @@ +# A basic configuration for Fedora's message broker, using the example callback +# which simply prints messages to standard output. +# +# This file is in the TOML format. +amqp_url = "amqps://elnbuildsync:@rabbitmq{{ env_suffix}}.fedoraproject.org/%2Fpubsub" +callback = "fedora_messaging.example:printer" +passive_declares = true + +[tls] +ca_cert = "/etc/fedora-messaging/cacert.pem" +keyfile = "/etc/fedora-messaging/elnbuildsync.key" +certfile = "/etc/fedora-messaging/elnbuildsync.crt" + +[client_properties] +app = "ELNBuildSync" +# Some suggested extra fields: +# URL of the project that provides this consumer +app_url = "https://github.com/fedora-eln/elnbuildsync" +# Contact emails for the maintainer(s) of the consumer - in case the +# broker admin needs to contact them, for e.g. +app_contacts_email = ["sgallagh@fedoraproject.org", "yselkowitz@fedoraproject.org"] + +[exchanges."amq.topic"] +type = "topic" +durable = true +auto_delete = false +arguments = {} + +# Queue names *must* be in the normal UUID format: run "uuidgen" and use the +# output as your queue name. If your queue is not exclusive, anyone can connect +# and consume from it, causing you to miss messages, so do not share your queue +# name. Any queues that are not auto-deleted on disconnect are garbage-collected +# after approximately one hour. +# +# If you require a stronger guarantee about delivery, please talk to Fedora's +# Infrastructure team. +[queues.elnbuildsync{{ env_suffix }}] +durable = true +auto_delete = false +exclusive = true +arguments = {} + +[[bindings]] +queue = "elnbuildsync{{ env_suffix }}" +exchange = "amq.topic" +routing_keys = [ + "org.fedoraproject.prod.buildsys.repo.init", + "org.fedoraproject.prod.buildsys.repo.done", + "org.fedoraproject.prod.buildsys.tag", + "org.fedoraproject.prod.buildsys.task.state.change" + ] + +[consumer_config] +example_key = "for my consumer" + +[qos] +prefetch_size = 0 +prefetch_count = 25 + +[log_config] +version = 1 +disable_existing_loggers = true + +[log_config.formatters.simple] +format = "[%(module)s %(levelname)s %(name)s] %(message)s" + +[log_config.handlers.console] +class = "logging.StreamHandler" +formatter = "simple" +stream = "ext://sys.stdout" + +[log_config.loggers.fedora_messaging] +level = "CRITICAL" +propagate = false +handlers = [] + +[log_config.loggers.twisted] +level = "CRITICAL" +propagate = false +handlers = ["console"] + +[log_config.loggers.pika] +level = "CRITICAL" +propagate = false +handlers = ["console"] + +# If your consumer sets up a logger, you must add a configuration for it +# here in order for the messages to show up. e.g. if it set up a logger +# called 'example_printer', you could do: +#[log_config.loggers.example_printer] +#level = "INFO" +#propagate = false +#handlers = ["console"] + +[log_config.root] +level = "ERROR" +handlers = ["console"] diff --git a/roles/openshift-apps/elnbuildsync/templates/fedora-messaging-config.yml.j2 b/roles/openshift-apps/elnbuildsync/templates/fedora-messaging-config.yml.j2 index 14d7f3aebb..f74219a324 100644 --- a/roles/openshift-apps/elnbuildsync/templates/fedora-messaging-config.yml.j2 +++ b/roles/openshift-apps/elnbuildsync/templates/fedora-messaging-config.yml.j2 @@ -4,10 +4,10 @@ metadata: name: fedora-messaging-config stringData: config.toml: |- - {{ ebs_fedora_messaging_config | indent(4) }} + {{ load_file('fedora-messaging-config.toml') | indent(4) }} cacert.pem: |- - {{ ebs_fedora_messaging_cacert | indent(4) }} + {{ (env == 'staging') | ternary(ebs_fedora_messaging_stg_cacert, ebs_fedora_messaging_cacert) | indent(4) }} elnbuildsync.crt: |- - {{ ebs_fedora_messaging_client_pem | indent(4) }} + {{ (env == 'staging') | ternary(ebs_fedora_messaging_client_stg_pem, ebs_fedora_messaging_client_pem) | indent(4) }} elnbuildsync.key: |- - {{ ebs_fedora_messaging_client_key | indent(4) }} + {{ (env == 'staging') | ternary(ebs_fedora_messaging_client_stg_key, ebs_fedora_messaging_client_key) | indent(4) }} diff --git a/vars/apps/elnbuildsync.yml b/vars/apps/elnbuildsync.yml index fc128d3139..298d59fba7 100644 --- a/vars/apps/elnbuildsync.yml +++ b/vars/apps/elnbuildsync.yml @@ -4,104 +4,3 @@ ebs_upstream_ref: 1.1.0 ebs_db_user: elnbuildsync ebs_db_name: elnbuildsync - -ebs_queue_username: distrobuildsync-eln - -ebs_fedora_messaging_config: | - # A basic configuration for Fedora's message broker, using the example callback - # which simply prints messages to standard output. - # - # This file is in the TOML format. - amqp_url = "amqps://fedora:@rabbitmq.fedoraproject.org/%2Fpubsub" - callback = "fedora_messaging.example:printer" - passive_declares = true - - [tls] - ca_cert = "/etc/fedora-messaging/cacert.pem" - keyfile = "/etc/fedora-messaging/distrobuildsync-eln.key" - certfile = "/etc/fedora-messaging/distrobuildsync-eln.crt" - - [client_properties] - app = "Example Application" - # Some suggested extra fields: - # URL of the project that provides this consumer - app_url = "https://github.com/fedora-infra/fedora-messaging" - # Contact emails for the maintainer(s) of the consumer - in case the - # broker admin needs to contact them, for e.g. - app_contacts_email = ["jcline@fedoraproject.org"] - - [exchanges."amq.topic"] - type = "topic" - durable = true - auto_delete = false - arguments = {} - - # Queue names *must* be in the normal UUID format: run "uuidgen" and use the - # output as your queue name. If your queue is not exclusive, anyone can connect - # and consume from it, causing you to miss messages, so do not share your queue - # name. Any queues that are not auto-deleted on disconnect are garbage-collected - # after approximately one hour. - # - # If you require a stronger guarantee about delivery, please talk to Fedora's - # Infrastructure team. - [queues.distrobuildsync-eln] - durable = true - auto_delete = false - exclusive = true - arguments = {} - - [[bindings]] - queue = "distrobuildsync-eln" - exchange = "amq.topic" - routing_keys = [ - "org.fedoraproject.prod.buildsys.repo.init", - "org.fedoraproject.prod.buildsys.repo.done", - "org.fedoraproject.prod.buildsys.tag", - "org.fedoraproject.prod.buildsys.task.state.change" - ] - - [consumer_config] - example_key = "for my consumer" - - [qos] - prefetch_size = 0 - prefetch_count = 25 - - [log_config] - version = 1 - disable_existing_loggers = true - - [log_config.formatters.simple] - format = "[%(module)s %(levelname)s %(name)s] %(message)s" - - [log_config.handlers.console] - class = "logging.StreamHandler" - formatter = "simple" - stream = "ext://sys.stdout" - - [log_config.loggers.fedora_messaging] - level = "CRITICAL" - propagate = false - handlers = [] - - [log_config.loggers.twisted] - level = "CRITICAL" - propagate = false - handlers = ["console"] - - [log_config.loggers.pika] - level = "CRITICAL" - propagate = false - handlers = ["console"] - - # If your consumer sets up a logger, you must add a configuration for it - # here in order for the messages to show up. e.g. if it set up a logger - # called 'example_printer', you could do: - #[log_config.loggers.example_printer] - #level = "INFO" - #propagate = false - #handlers = ["console"] - - [log_config.root] - level = "ERROR" - handlers = ["console"]