You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-msvsphere.ci/roles/koji_cli/tasks/main.yml

70 lines
2.4 KiB

---
- 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}}" }
- { key: 'keytab', value: "{{ koji_cli_keytab }}" }
- { key: 'principal', value: "{{ koji_cli_principal }}" }