Adds koji_cli role

master
Eugene Zamriy 11 months ago
parent b507b53121
commit 068cbb7263
Signed by: ezamriy
GPG Key ID: 7EBF95C7DCFA496C

@ -0,0 +1,36 @@
# msvsphere.ci.koji_cli
An Ansible role that installs and configures Koji CLI tools.
## Variables
| Variable | Default value | Type | Description | Required |
| ----------------- | ------------- | ---- | ------------------------- | -------- |
| koji_domain_name | | str | Koji server domain name. | yes |
| koji_cli_user | | str | Koji CLI tools user name. | no |
| koji_profile | "koji" | str | Koji profile name. | no |
| koji_ca_cert_path | | str | Koji CA certificate path. | no |
| koji_topdir | "/mnt/koji" | str | Koji top directory path. | no |
If `koji_cli_user` is omitted, the role will modify the system-wide configuration
file `/etc/koji.conf`, otherwise, a configuration file will be generated for the
specified user.
## Example playbook
```yaml
---
- hosts: all
roles:
- role: msvsphere.ci.koji_cli
koji_domain_name: 'build.msvsphere.test'
koji_ca_cert_path: '/etc/pki/koji/koji-ca.crt'
```
## License
MIT.
## Authors
* [Eugene Zamriy](mailto:ezamriy@msvsphere-os.ru)

@ -0,0 +1,6 @@
---
koji_domain_name:
koji_cli_user:
koji_profile: 'koji'
koji_ca_cert_path:
koji_topdir: '/mnt/koji'

@ -0,0 +1,35 @@
---
argument_specs:
main:
short_description: A role that installs and configures Koji CLI tools.
author: Eugene Zamriy
version_added: '0.1.4'
options:
koji_domain_name:
description: Koji server domain name.
type: str
required: true
koji_cli_user:
description:
- Koji CLI tools user name.
- If omitted, the system-wide configuration file /etc/koji.conf will be updated.
type: 'str'
required: false
koji_profile:
description: Koji profile name.
default: 'koji'
type: 'str'
required: false
koji_ca_cert_path:
description: Koji CA certificate path.
type: 'str'
required: false
koji_topdir:
description: Koji top directory path.
default: '/mnt/koji'
type: 'str'
required: false

@ -0,0 +1,15 @@
---
galaxy_info:
author: Eugene Zamriy
description: A role that installs and configures Koji CLI tools.
company: Softline PJSC
license: MIT
min_ansible_version: 2.13
platforms:
- name: EL
versions:
- "9"
galaxy_tags:
- koji
dependencies: []

@ -0,0 +1,68 @@
---
- name: Check if required variables are defined
ansible.builtin.fail:
msg: "{{ item }} is not defined or empty"
when: |
(vars[item] is undefined)
or (vars[item] is none)
or (vars[item] | trim | length == 0)
with_items:
- koji_domain_name
- koji_profile
- koji_topdir
- name: Install Koji client
ansible.builtin.dnf:
name: koji
state: installed
- block:
- name: Configure system-wide Koji client
community.general.ini_file:
path: /etc/koji.conf
section: "{{ koji_profile }}"
option: "{{ item.key }}"
value: "{{ item.value }}"
with_items: "{{ config_vars | selectattr('value') }}"
when: not koji_cli_user
- name: Configure per user Koji client
block:
- name: Get Koji client user information
ansible.builtin.getent:
database: passwd
key: "{{ koji_cli_user }}"
- name: Get user group information
ansible.builtin.getent:
database: group
key: "{{ getent_passwd[koji_cli_user][2]}}"
- name: Create user ~/.koji directory
ansible.builtin.file:
path: "{{ (getent_passwd[koji_cli_user][4], '.koji') | path_join }}"
state: directory
owner: "{{ koji_cli_user }}"
group: "{{ getent_group | first }}"
mode: '0700'
- name: Configure user Koji client
community.general.ini_file:
path: "{{ (getent_passwd[koji_cli_user][4], '.koji', 'config') | path_join }}"
section: "{{ koji_profile }}"
option: "{{ item.key }}"
value: "{{ item.value }}"
owner: "{{ koji_cli_user }}"
group: "{{ getent_group | first }}"
mode: '0600'
with_items: "{{ config_vars | selectattr('value') }}"
when: koji_cli_user
vars:
config_vars:
- { key: 'authtype', value: 'kerberos' }
- { key: 'server', value: "https://{{ koji_domain_name }}/kojihub" }
- { key: 'weburl', value: "https://{{ koji_domain_name }}/koji" }
- { key: 'topurl', value: "https://{{ koji_domain_name }}/kojifiles" }
- { key: 'topdir', value: "{{ koji_topdir }}" }
- { key: 'serverca', value: "{{ koji_ca_cert_path}}" }
Loading…
Cancel
Save