Merge branch 'master' of /git/ansible

This commit is contained in:
Rick Elrod 2017-08-04 21:16:29 +00:00
commit 88aecf80ce
6 changed files with 30 additions and 105 deletions

View file

@ -210,7 +210,11 @@ REQUIRED_GROUPS = {
'rpms/*': ['packager'],
}
{% if env == 'staging' %}
PDC_URL = 'https://pdc.stg.fedoraproject.org/rest_api/v1/'
{% else %}
PDC_URL = 'https://pdc.fedoraproject.org/rest_api/v1/'
{% endif %}
GITOLITE_BACKEND = 'distgit'

View file

@ -12,6 +12,7 @@
- httpd
- mod_ssl
- mod_auth_gssapi
- python-fedmsg-genacls
- /usr/sbin/semanage
tags:
- distgit
@ -219,6 +220,12 @@
- config
- distgit
- name: install the fedmsg configuration
template: src=fedmsg-genacls-config.py dest=/etc/fedmsg.d/genacls.py
owner=root group=root mode=0644
tags:
- distgit
- name: remove file pre-dating pagure over dist-git
file: path={{ item }} state=absent
with_items:
@ -230,13 +237,6 @@
- config
- distgit
- name: remove packages pre-dating pagure over dist-git
yum: pkg={{ item }} state=absent
with_items:
- python-fedmsg-genacls
tags:
- distgit
- name: Get admin users
command: "/srv/web/infra/ansible/scripts/users-from-fas @sysadmin-main {{ admin_groups }}"
register: admin_user_list

View file

@ -1,5 +1,5 @@
config = {
'genacls.consumer.enabled': True,
'genacls.consumer.enabled': False,
'genacls.consumer.delay': 5, # 5 seconds
# New world

View file

@ -8,14 +8,23 @@ Its goal is to generate all the <pkg>-owner email aliases we provide
import requests
# TODO: Change me
pagure_url = 'http://127.0.0.1:5000'
pagure_url = 'https://src.fedoraproject.org/'
pagure_group_url = pagure_url + '/api/0/group/{group}'
pagure_projects_url = pagure_url + '/api/0/projects'
pagure_projects = requests.get(pagure_projects_url).json()['projects']
project_to_email = {}
for project in pagure_projects:
def get_pagure_projects():
pagure_projects_url = pagure_url + '/api/0/projects?page=1&per_page=100'
while pagure_projects_url:
response = requests.get(pagure_projects_url)
data = response.json()
for project in data['projects']:
yield project
# This is set to None on the last page.
pagure_projects_url = data['pagination']['next']
for project in get_pagure_projects():
users = set(project['access_users']['owner']) | \
set(project['access_users']['admin']) | \
set(project['access_users']['commit'])

View file

@ -1,79 +0,0 @@
#!/usr/bin/python -tt
"""
This script is ran as a cronjob and bastion.
Its goal is to generate all the <pkg>-owner email aliases we provide
"""
import os
import sys
import urllib2
from fedora.client import BaseClient, ServerError, AuthError
import ConfigParser
import requests
config = ConfigParser.ConfigParser()
config.read('/etc/fas.conf')
pkgdb_url = 'https://admin.fedoraproject.org/pkgdb'
fas = BaseClient('https://admin.fedoraproject.org/accounts',
username=config.get('global', 'login').strip('"'),
password=config.get('global', 'password').strip('"'))
try:
pkgdb_data = requests.get('%s/api/notify/?format=json' % pkgdb_url,
verify=True).json()
fas_data = fas.send_request('/user/email_list', auth=True)
fas_groups = fas.send_request(
'/group/type_list', auth=True, req_params={'grptype': 'pkgdb'})
except ServerError, e:
print >> sys.stderr, '%s' % e
sys.exit(1)
except AuthError, e:
print >> sys.stderr, '%s: %s' % (e.exc, e.message)
sys.exit(1)
except (urllib2.HTTPError,urllib2.URLError), e:
print >> sys.stderr, '%s' % e
sys.exit(1)
else:
pkgs = pkgdb_data['packages']
if len(pkgs) < 500:
print >> sys.stderr, 'Too few packages, something is wrong'
sys.exit(1)
email_list = fas_data['emails']
group_mail = {}
for group in fas_groups.groups:
group_mail[group.name] = group.mailing_list
contactlist = {}
for pkg, ccusers in pkgs.iteritems():
emails = []
for user in ccusers:
if user in email_list:
emails.append(email_list[user])
elif user.startswith('group::'):
user = user.replace('group::', '')
if user in group_mail and group_mail[user]:
emails.append(group_mail[user])
else:
print >> sys.stderr, 'Strange user `%s`, not in '\
'email_list nor in group_mail, badly set-up '\
'group?\n' % user
else:
print >> sys.stderr, 'Strange user `%s`, not in '\
'email_list and not a group\n' % user
if pkg.lower() in contactlist:
contactlist[pkg.lower()] = contactlist[pkg.lower()].union(emails)
else:
contactlist[pkg.lower()] = set(emails)
for pkg, emails in sorted(contactlist.iteritems()):
print '%s-owner: %s' % (pkg.lower(),','.join(sorted(emails)))
for group in fas_groups.groups:
print '{0}: {1}'.format(group.name, group.mailing_list)

View file

@ -1,26 +1,15 @@
---
# Email alias set-up
- name: Install the Python script to get the <pkg>-owner email alias (non-staging)
copy:
src: owner-email.py
dest: /usr/local/bin/owner-email.py
owner: root
group: root
mode: 0755
when: env != 'staging'
tags:
- install
- name: Install the Python script to get the <pkg>-owner email alias (staging)
- name: Install the Python script to get the <pkg>-owner email alias
copy:
src: owner-email-from-pagure.py
dest: /usr/local/bin/owner-email.py
owner: root
group: root
mode: 0755
when: env == 'staging'
tags:
- install
- packager_alias
- name: Install the script to generate the <pkg>-owner email alias
copy:
@ -31,6 +20,7 @@
mode: 0755
tags:
- install
- packager_alias
#
# Since this host has mail aliases, it's a mail hub. Compress logs since there will be a ton of them
@ -40,3 +30,4 @@
copy: src=syslog dest=/etc/logrotate.d/syslog owner=root group=root
tags:
- install
- packager_alias