1
0
Fork 0
forked from infra/ansible

Scaffolding for jira-sync in staging Openshift

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
This commit is contained in:
Aurélien Bompard 2026-06-26 23:23:50 +02:00
commit 98276d6b77
Signed by untrusted user: abompard
GPG key ID: 31584CFEB9BF64AD
13 changed files with 571 additions and 0 deletions

View file

@ -0,0 +1,99 @@
#
# Jira Sync
# https://github.com/Zlopez/jira_sync
#
- name: Make the app be real
#hosts: os_control[0]:os_control_stg[0]
hosts: os_control_stg[0]
user: root
gather_facts: false
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
roles:
# Fedora Messaging
- name: Setup Rabbit Queue
ansible.builtin.include_role:
name: rabbit/queue
vars:
queue_username: jira-sync{{ env_suffix }}
queue_name: jira-sync{{ env_suffix }}
queue_routing_keys:
- "org.fedoraproject.*.bugzilla.bug.update"
queue_thresholds:
warning: 10
critical: 100
- role: openshift/secret-file
secret_file_app: jira-sync
secret_file_secret_name: fedora-messaging-ca
secret_file_key: cacert.pem
secret_file_privatefile: "rabbitmq/{{env}}/ca-combined.crt"
- role: openshift/secret-file
secret_file_app: jira-sync
secret_file_secret_name: fedora-messaging-cert
secret_file_key: cert.pem
secret_file_privatefile: "rabbitmq/{{env}}/pki/issued/jira-sync{{env_suffix}}.crt"
- role: openshift/secret-file
secret_file_app: jira-sync
secret_file_secret_name: fedora-messaging-key
secret_file_key: key.pem
secret_file_privatefile: "rabbitmq/{{env}}/pki/private/jira-sync{{env_suffix}}.key"
# Openshift
- role: openshift/project
project_app: jira-sync
project_description: "Sync various sources to JIRA project"
project_appowners:
- zlopez
- abompard
tags:
- apply-appowners
- role: openshift/object
object_app: jira-sync
object_file: imagestream.yml
object_objectname: imagestream.yml
- role: openshift/object
object_app: jira-sync
object_template: buildconfig.yml.j2
object_objectname: buildconfig.yml
- role: openshift/object
object_app: jira-sync
object_template: configmap.yml.j2
object_objectname: configmap.yml
- role: openshift/object
object_app: jira-sync
object_template: secrets.yml.j2
object_objectname: secrets.yml
- role: openshift/object
object_app: jira-sync
object_template: deployment.yml.j2
object_objectname: deployment.yml
- role: openshift/object
object_app: jira-sync
object_template: cron.yml.j2
object_objectname: cron.yml
- role: openshift/start-build
start_build_app: jira-sync
start_build_buildname: app
tags:
- never
- build
- role: openshift/rollout
rollout_app: jira-sync
rollout_dname: app
tags:
- never
- rollout

View file

@ -0,0 +1,5 @@
---
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: jira_sync

View file

@ -0,0 +1,32 @@
---
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: jira-sync
labels:
build: jira-sync
spec:
source:
type: Git
git:
#uri: https://github.com/Zlopez/jira_sync.git
uri: https://github.com/abompard/jira_sync.git
ref: "{{ (env == 'staging')|ternary('main', 'main') }}"
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
namespace: openshift
name: python:3.12-ubi9
noCache: true
output:
to:
kind: ImageStreamTag
name: jira_sync:latest
triggers:
- type: ConfigChange
- type: ImageChange
- type: GitHub
github:
secret: "{{ (env == 'staging')|ternary(jira-sync_stg_webhook_secret, jira-sync_prod_webhook_secret) }}"

View file

@ -0,0 +1,24 @@
abompard = "abompard@redhat.com"
AdamWill = "awilliam@redhat.com"
amoloney = "amoloney@redhat.com"
arrfab = "farrotin@redhat.com"
ashcrow = "smilner@redhat.com"
carlwgeorge = "carl@redhat.com"
dherrerace = "dherrera@redhat.com"
dkirwan = "dkirwan@redhat.com"
ekidney = "ekidney@redhat.com"
gordonmessmer = "gmessmer@redhat.com"
gridhead = "akdhar@redhat.com"
gwmngilfen = "gsutclif@redhat.com"
jednorozec = "thrcka@redhat.com"
jnsamyak = "samjain@redhat.com"
jspaleta = "jspaleta@redhat.com"
lenkaseg = "lsegura@redhat.com"
mattdm = "mattdm@redhat.com"
nilsph = "nphilipp@redhat.com"
nirik = "kfenzi@redhat.com"
pbokoc = "pbokoc@redhat.com"
pookee = "jbley@redhat.com"
rcallwoo = "rcallwoo@redhat.com"
ryanlerch = "rlerch@redhat.com"
zlopez = "mkonecny@redhat.com"

View file

@ -0,0 +1,142 @@
# General configuration
[general.jira]
instance_url = "https://redhat.atlassian.net" # JIRA instance URL
project = "CLE" # Name of the project to sync tickets to
username = "fedora-bots-admins@redhat.com"
token = "$secrets.jira_token" # API token to use for authentication
default_issue_type = "Story" # Issue type to use when creating new issue in JIRA
label = "jira_sync" # Label used for all issues created by this script
story_points_field = "customfield_10028" # JIRA issue field used for story points (this could be custom field)
external_url_field = "customfield_10766" # JIRA field used for external URL (this is used to match the JIRA issue with upstream issue)
blocked_field = "customfield_10517" # JIRA issue field used for marking ticket as blocked
# Map the boolean values to JIRA field values
[general.jira.blocked_values]
true = 10852
false = 10853
# Map the ticket state to JIRA project state
# Recognizable states are:
# * new = ticket is open and nobody is assigned to it
# * assigned = ticket is assigned to user
# * blocked = ticket is blocked (see blocked_label in corresponding section)
# * closed = ticket is closed
[general.jira.statuses]
new = "New"
assigned = "In Progress"
blocked = "In Progress"
closed = "Closed"
# Pagure configuration
[instances."pagure.io"]
type = "pagure"
enabled = true # Enable/Disable Pagure instance
instance_url = "https://pagure.io/" # URL for pagure endpoint
blocked_label = "blocked" # Label that is marking blocked issues
usermap = "pagureio_jira_usermap.toml" # Map pagure.io to JIRA users
# converts specific label to story point
labels_to_story_points = { "points::1" = 1, "points::2" = 2, "points::3" = 3, "points::5" = 5, "points::8" = 8, "points::13" = 13 }
# converts priority labels to priority in JIRA
labels_to_priority = { "Priority::High" = "Critical", "Priority::Medium" = "Major", "Priority::Low" = "Minor" }
# retrieve also closed tickets that were closed in last X days
# if set to 0, only retrieves open tickets
retrieve_closed_days_ago = 3
[[instances."pagure.io".query_repositories]]
namespace = "fedora-infra"
label = "cle" # Label marking issues to be synchronized
[instances."pagure.io".repositories]
# List of repositories to check for tickets
# When label is set, only tickets with this label will be covered
"Fedora-Council/council-docs" = {}
"Fedora-Council/tickets" = {}
"fedora-docs" = {}
"fedora-docs/quick-docs" = {}
"fedora-infra/ansible" = {enabled = false} # The Ansible repo doesnt have issues
"fedora-infra/arc" = {}
"fedora-pdr" = {}
# GitHub configuration
[instances."github.com"]
type = "github"
enabled = true
instance_url = "https://github.com"
instance_api_url = "https://api.github.com"
token = "$secrets.githubcom_token"
label = "cle"
blocked_label = "blocked"
usermap = "githubcom_jira_usermap.toml"
# converts specific label to story point
labels_to_story_points = { "points::1" = 1, "points::2" = 2, "points::3" = 3, "points::5" = 5, "points::8" = 8, "points::13" = 13 }
# converts priority labels to priority in JIRA
labels_to_priority = { "Priority::High" = "Critical", "Priority::Medium" = "Major", "Priority::Low" = "Minor" }
# retrieve also closed tickets that were closed in last X days
# if set to 0, only retrieves open tickets
retrieve_closed_days_ago = 3
[[instances."github.com".query_repositories]]
org = "fedora-infra"
[[instances."github.com".query_repositories]]
org = "CentOS"
[instances."github.com".repositories]
"neoave/mrack" = {}
"os-autoinst/openQA-python-client" = {}
"temtee/tmt" = {}
"Zlopez/jira_sync" = { label = "cle" }
# GitLab configuration
[instances."gitlab.com"]
type = "gitlab"
enabled = true
instance_url = "https://gitlab.com"
instance_api_url = "https://gitlab.com/api/v4"
token = "$secrets.gitlabcom_token"
blocked_label = "blocked"
usermap = "gitlabcom_jira_usermap.toml"
# converts specific label to story point
labels_to_story_points = { "points::1" = 1, "points::2" = 2, "points::3" = 3, "points::5" = 5, "points::8" = 8, "points::13" = 13 }
# converts priority labels to priority in JIRA
labels_to_priority = { "Priority::High" = "Critical", "Priority::Medium" = "Major", "Priority::Low" = "Minor" }
# retrieve also closed tickets that were closed in last X days
# if set to 0, only retrieves open tickets
retrieve_closed_days_ago = 3
[[instances."gitlab.com".query_repositories]]
org = "fedora/design"
label = "cle"
[[instances."gitlab.com".query_repositories]]
org = "fedora/docs"
label = "cle"
[instances."gitlab.com".repositories]
"CentOS/infra/tracker" = { blocked_label = "status::blocked" }
"fedora/legal/fedora-legal-docs" = {}
# Forgejo configuration for codeberg.org
[instances."codeberg.org"]
type = "forgejo"
enabled = true
instance_url = "https://codeberg.org"
# instance_api_url = "https://codeberg.org/api/v1"
token = "$secrets.codebergorg_token"
blocked_label = "blocked"
usermap = "codebergorg_jira_usermap.toml"
# converts specific label to story point
labels_to_story_points = { "points::1" = 1, "points::2" = 2, "points::3" = 3, "points::5" = 5, "points::8" = 8, "points::13" = 13 }
# converts priority labels to priority in JIRA
labels_to_priority = { "Priority::High" = "Critical", "Priority::Medium" = "Major", "Priority::Low" = "Minor" }
# retrieve also closed tickets that were closed in last X days
# if set to 0, only retrieves open tickets
retrieve_closed_days_ago = 3
[[instances."codeberg.org".query_repositories]]
org = "fedora"
label = "cle"
[instances."codeberg.org".repositories]

View file

@ -0,0 +1,25 @@
{% macro load_file(filename) %}{% include filename %}{%- endmacro -%}
---
apiVersion: v1
kind: List
metadata: {}
items:
- apiVersion: v1
kind: ConfigMap
metadata:
name: configs
labels:
app: jira-sync
data:
config.toml: |-
{{ load_file('config.toml') | indent(6) }}
codebergorg_jira_usermap.toml: |-
{{ load_file('codebergorg_jira_usermap.toml') | indent(6) }}
githubcom_jira_usermap.toml: |-
{{ load_file('githubcom_jira_usermap.toml') | indent(6) }}
gitlabcom_jira_usermap.toml: |-
{{ load_file('gitlabcom_jira_usermap.toml') | indent(6) }}
pagureio_jira_usermap.toml: |-
{{ load_file('pagureio_jira_usermap.toml') | indent(6) }}
fedora-messaging.toml: |-
{{ load_file('fedora-messaging.toml') | indent(6) }}

View file

@ -0,0 +1,35 @@
# Run the sync
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: sync
spec:
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 3
concurrencyPolicy: Forbid
schedule: "0 */4 * * *"
startingDeadlineSeconds: 500
jobTemplate:
spec:
template:
spec:
restartPolicy: Never
containers:
- name: app
image: image-registry.openshift-image-registry.svc:5000/jira-sync/jira_sync:latest
command: ["poetry", "run", "jira_sync", "sync-tickets", "--config", "/etc/jira-sync/config.toml"]
volumeMounts:
- name: config-volume
mountPath: /etc/jira-sync
readOnly: true
- name: secrets
mountPath: /etc/jira-sync-secrets
readOnly: true
volumes:
- name: config-volume
configMap:
name: configs
- name: secrets
secret:
secretName: secrets

View file

@ -0,0 +1,60 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
labels:
app: jira-sync
deployment: app
annotations:
image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"jira_sync:latest","namespace":"jira-sync"},"fieldPath":"spec.template.spec.containers[?(@.name==\"app\")].image"}]'
spec:
replicas: 1
selector:
matchLabels:
app: jira-sync
strategy:
type: Recreate
template:
metadata:
labels:
app: jira-sync
deployment: app
spec:
containers:
- name: app
image: image-registry.openshift-image-registry.svc:5000/jira-sync/jira_sync:latest
imagePullPolicy: Always
command: ["poetry", "run", "fedora-messaging", "--conf", "/etc/jira-sync/fedora-messaging.toml"]
volumeMounts:
- name: config
mountPath: /etc/jira-sync
readOnly: true
- name: secrets
mountPath: /etc/jira-sync-secrets
readOnly: true
- name: fedora-messaging-ca
mountPath: /etc/pki/fedora-messaging/ca
readOnly: true
- name: fedora-messaging-key
mountPath: /etc/pki/fedora-messaging/key
readOnly: true
- name: fedora-messaging-cert
mountPath: /etc/pki/fedora-messaging/cert
readOnly: true
volumes:
- name: config-volume
configMap:
name: configs
- name: secrets
secret:
secretName: secrets
- name: fedora-messaging-ca
secret:
secretName: fedora-messaging-ca
- name: fedora-messaging-key
secret:
secretName: fedora-messaging-key
- name: fedora-messaging-cert
secret:
secretName: fedora-messaging-cert

View file

@ -0,0 +1,36 @@
amqp_url = "amqps://jira-sync{{ env_suffix }}:@rabbitmq{{ env_suffix }}.fedoraproject.org/%2Fpubsub"
callback = "jira_sync.consumer:Consumer"
passive_declares = true
topic_prefix = "org.fedoraproject.{{ env_short }}"
[tls]
ca_cert = "/etc/pki/fedora-messaging/ca/cacert.pem"
certfile = "/etc/pki/fedora-messaging/cert/cert.pem"
keyfile = "/etc/pki/fedora-messaging/key/key.pem"
[client_properties]
app = "Jira Sync"
# If the exchange or queue name has a "." in it, use quotes as seen here.
[exchanges."amq.topic"]
type = "topic"
durable = true
auto_delete = false
arguments = {}
[queues."jira-sync{{ env_suffix }}"]
durable = true
auto_delete = false
exclusive = false
arguments = {}
[[bindings]]
queue = "fedbadges{{ env_suffix }}"
exchange = "amq.topic"
routing_keys = ["org.fedoraproject.prod.bugzilla.bug.update"]
[consumer_config]
config_file = "config.toml"
run_mode = "READ_ONLY"

View file

@ -0,0 +1,33 @@
abompard = "abompard@redhat.com"
AdamWill = "awilliam@redhat.com"
amedvede = "amedvede@redhat.com"
amoloney4 = "amoloney@redhat.com"
arrfab = "farrotin@redhat.com"
ashcrow = "smilner@redhat.com"
bconoboy = "bconoboy@redhat.com"
carlwgeorge = "carl@redhat.com"
davidkirwan = "dkirwan@redhat.com"
dherrerace = "dherrera@redhat.com"
ekidneyrh = "ekidney@redhat.com"
gordonmessmer = "gmessmer@redhat.com"
GregSutcliffe = "gsutclif@redhat.com"
gridhead = "akdhar@redhat.com"
humaton = "thrcka@redhat.com"
james-antill = "jantill@redhat.com"
jbley1218 = "jbley@redhat.com"
jnsamyak = "samjain@redhat.com"
jspaleta = "jspaleta@redhat.com"
kashyapc = "kchamart@redhat.com"
kparal = "kparal@redhat.com"
LenkaSeg = "lsegura@redhat.com"
mattdm = "mattdm@redhat.com"
nirik = "kfenzi@redhat.com"
nphilipp = "nphilipp@redhat.com"
pbokoc = "pbokoc@redhat.com"
phsmoura = "pmoura@redhat.com"
ppolakov = "ppolakov@redhat.com"
psklenar = "psklenar@redhat.com"
rcallwoo = "rcallwoo@redhat.com"
ryanlerch = "rlerch@redhat.com"
skycastlelily = "lnie@redhat.com"
Zlopez = "mkonecny@redhat.com"

View file

@ -0,0 +1,34 @@
abompard = "abompard@redhat.com"
AdamWill = "awilliam@redhat.com"
amedvede = "amedvede@redhat.com"
amoloney = "amoloney@redhat.com"
arrfab = "farrotin@redhat.com"
blc2 = "bconoboy@redhat.com"
carlwgeorge = "carl@redhat.com"
davidkirwan = "dkirwan@redhat.com"
dherrera_rh = "dherrera@redhat.com"
ekidney = "ekidney@redhat.com"
geppettofedora = "jantill@redhat.com"
gordonmessmer = "gmessmer@redhat.com"
gridhead = "akdhar@redhat.com"
gwmngilfen = "gsutclif@redhat.com"
humaton = "thrcka@redhat.com"
jbley = "jbley@redhat.com"
jspaleta = "jspaleta@redhat.com"
kchamart = "kchamart@redhat.com"
kfenzi = "kfenzi@redhat.com"
nirik = "kfenzi@redhat.com"
kparal = "kparal@redhat.com"
LenkaSeg = "lsegura@redhat.com"
mattdm = "mattdm@redhat.com"
nphilipp1 = "nphilipp@redhat.com"
pbokoc = "pbokoc@redhat.com"
phsmoura = "pmoura@redhat.com"
ppolakov = "ppolakov@redhat.com"
psklenar1 = "psklenar@redhat.com"
rcallwoo = "rcallwoo@redhat.com"
ryanlerch = "rlerch@redhat.com"
samyak-jn = "samjain@redhat.com"
skycastlelily = "lnie@redhat.com"
smilnerrh = "smilner@redhat.com"
Zlopez = "mkonecny@redhat.com"

View file

@ -0,0 +1,36 @@
abompard = "abompard@redhat.com"
adamwill = "awilliam@redhat.com"
amedvede = "amedvede@redhat.com"
amoloney = "amoloney@redhat.com"
ancarrol = "ancarrol@redhat.com"
arrfab = "farrotin"
blc = "bconoboy"
carlwgeorge = "carl@redhat.com"
dherrera = "dherrera@redhat.com"
dkirwan = "dkirwan"
ekidney = "ekidney@redhat.com"
gordonmessmer = "rh-ee-gmessmer"
gwmngilfen = "gsutclif@redhat.com"
humaton = "thrcka@redhat.com"
james = "jantill@redhat.com"
jbley = "jbley@redhat.com"
jgroman = "rh-ee-jgroman"
jnsamyak = "samjain@redhat.com"
jspaleta = "rh-ee-jspaleta"
kashyapc = "kchamart@redhat.com"
kevin = "kfenzi.fedora"
kparal = "kparal@redhat.com"
lenkaseg = "lsegura@redhat.com"
lnie = "lnie@redhat.com"
lruzicka = "lruzicka@redhat.com"
mattdm = "mattdm@redhat.com"
nphilipp = "nphilipp@redhat.com"
patrikp = "ppolakov@redhat.com"
pbokoc = "pbokoc@redhat.com"
phsmoura = "pmoura@redhat.com"
psklenar = "psklenar@redhat.com"
rcallwoo = "rh-ee-rcallwoo"
ryanlerch = "rlerch@redhat.com"
smilner = "rhn-it-smilner"
t0xic0der = "akdhar@redhat.com"
zlopez = "mkonecny@redhat.com"

View file

@ -0,0 +1,10 @@
---
kind: Secret
apiVersion: v1
metadata:
name: jira-sync
stringData:
jira-token: "{{ (env == 'staging')|ternary(jira-sync_stg_jira_token, jira-sync_prod_jira_token) }}"
githubcom-token: "{{ (env == 'staging')|ternary(jira-sync_stg_githubcom_token, jira-sync_prod_githubcom_token) }}"
gitlabcom-token: "{{ (env == 'staging')|ternary(jira-sync_stg_gitlabcom_token, jira-sync_prod_gitlabcom_token) }}"
codebergorg-token: "{{ (env == 'staging')|ternary(jira-sync_stg_codebergorg_token, jira-sync_prod_codebergorg_token) }}"