From 9d3d38e3d46a0ebcb5e471105ddf877c4c3ed781 Mon Sep 17 00:00:00 2001 From: Bruno Goncalves Date: Feb 19 2018 12:53:59 +0000 Subject: [PATCH 1/3] updated how to enable copr repositories --- diff --git a/roles/standard-test-beakerlib/tasks/main.yml b/roles/standard-test-beakerlib/tasks/main.yml index e803582..44f8289 100644 --- a/roles/standard-test-beakerlib/tasks/main.yml +++ b/roles/standard-test-beakerlib/tasks/main.yml @@ -2,17 +2,11 @@ - delegate_to: "{{ test_runner_inventory_name }}" block: - - name: Add restraint repo for restraint-rhts using DNF - shell: dnf copr enable -y bpeck/restraint - ignore_errors: True - when: "hostvars[test_runner_inventory_name]['is_dnf_os'] | bool" - - - name: Add restraint repo for restraint-rhts using YUM - block: - - package: name=yum-plugin-copr - - shell: yum copr -y enable bpeck/restraint - ignore_errors: True - when: "hostvars[test_runner_inventory_name]['is_yum_os'] | bool" + - include_tasks: >- + "../../str-common/tasks/pkgs-{{hostvars[test_runner_inventory_name]['ansible_pkg_mgr']}}.yml" + vars: + copr_repos: "bpeck/restraint" + name: "Enable copr repositories" - name: Install the beakerlib requirements package: name={{item}} state=present diff --git a/roles/str-common/tasks/pkgs-dnf.yml b/roles/str-common/tasks/pkgs-dnf.yml index 554a817..f042c8e 100644 --- a/roles/str-common/tasks/pkgs-dnf.yml +++ b/roles/str-common/tasks/pkgs-dnf.yml @@ -23,3 +23,12 @@ - "{{ pkgs_debuginfo_req }}" when: - pkgs_debuginfo_req + +- block: + - package: name=dnf-plugins-core + - shell: dnf copr enable -y {{item}} + with_items: + - "{{copr_repos}}" + name: Enable copr repos using DNF + ignore_errors: True + when: copr_repos is defined diff --git a/roles/str-common/tasks/pkgs-yum.yml b/roles/str-common/tasks/pkgs-yum.yml index a23042e..8865e80 100644 --- a/roles/str-common/tasks/pkgs-yum.yml +++ b/roles/str-common/tasks/pkgs-yum.yml @@ -21,3 +21,12 @@ - "{{ pkgs_debuginfo_req }}" when: - pkgs_debuginfo_req + +- block: + - package: name=yum-plugin-copr + - shell: yum copr -y {{item}} + with_items: + - "{{copr_repos}}" + name: Enable copr repos using YUM + ignore_errors: True + when: copr_repos is defined From ecee33a8f18958c964e2b7ccff9fdd9041a5ee2e Mon Sep 17 00:00:00 2001 From: Bruno Goncalves Date: Feb 19 2018 13:24:01 +0000 Subject: [PATCH 2/3] updated how to enable copr repositories for rhts role --- diff --git a/roles/standard-test-beakerlib/tasks/main.yml b/roles/standard-test-beakerlib/tasks/main.yml index 44f8289..2172110 100644 --- a/roles/standard-test-beakerlib/tasks/main.yml +++ b/roles/standard-test-beakerlib/tasks/main.yml @@ -3,7 +3,7 @@ - delegate_to: "{{ test_runner_inventory_name }}" block: - include_tasks: >- - "../../str-common/tasks/pkgs-{{hostvars[test_runner_inventory_name]['ansible_pkg_mgr']}}.yml" + ../../str-common/tasks/pkgs-{{hostvars[test_runner_inventory_name]['ansible_pkg_mgr']}}.yml vars: copr_repos: "bpeck/restraint" name: "Enable copr repositories" diff --git a/roles/standard-test-rhts/tasks/main.yml b/roles/standard-test-rhts/tasks/main.yml index 1284f69..0558ab0 100644 --- a/roles/standard-test-rhts/tasks/main.yml +++ b/roles/standard-test-rhts/tasks/main.yml @@ -3,19 +3,25 @@ package: name={{item}} state=latest with_items: - rsync # need rsync for Ansible synchronize module - - dnf-plugins-core # need COPR plugin - openssh-server - beakerlib - make - createrepo -- name: Enable COPR repo for restraint - shell: dnf copr -y enable bpeck/restraint +- name: Enable bpeck/restraint COPR repo for restraint + set_fact: + req_copr_repos: ["bpeck/restraint"] -- name: Enable COPR repo for beakerlib-libraries - shell: dnf copr -y enable mvadkert/beakerlib-libraries +- name: Enable beakerlib-libraries COPR repo + set_fact: + req_copr_repos: "{{ req_copr_repos + ['mvadkert/beakerlib-libraries'] }}" when: use_beakerlib_libraries +- include_tasks: ../../str-common/tasks/pkgs-{{ ansible_pkg_mgr | trim}}.yml + vars: + copr_repos: "{{req_copr_repos}}" + name: "Enable copr repositories" + - name: Install restraint from COPR repo package: name={{item}} state=latest with_items: diff --git a/roles/str-common/tasks/pkgs-dnf.yml b/roles/str-common/tasks/pkgs-dnf.yml index f042c8e..1f06e1b 100644 --- a/roles/str-common/tasks/pkgs-dnf.yml +++ b/roles/str-common/tasks/pkgs-dnf.yml @@ -3,6 +3,8 @@ package: name={{item}} state=present with_items: - "{{ pkgs_ordinary_req }}" + when: + - pkgs_ordinary_req is defined - name: Install the common requirements on target package: name={{item}} state=present @@ -22,7 +24,7 @@ with_items: - "{{ pkgs_debuginfo_req }}" when: - - pkgs_debuginfo_req + - pkgs_debuginfo_req is defined - block: - package: name=dnf-plugins-core diff --git a/roles/str-common/tasks/pkgs-yum.yml b/roles/str-common/tasks/pkgs-yum.yml index 8865e80..3d7b1dd 100644 --- a/roles/str-common/tasks/pkgs-yum.yml +++ b/roles/str-common/tasks/pkgs-yum.yml @@ -3,6 +3,8 @@ package: name={{item}} state=present with_items: - "{{ pkgs_ordinary_req }}" + when: + - pkgs_ordinary_req is defined - name: Install the common requirements on target package: name={{item}} state=present @@ -20,7 +22,7 @@ with_items: - "{{ pkgs_debuginfo_req }}" when: - - pkgs_debuginfo_req + - pkgs_debuginfo_req is defined - block: - package: name=yum-plugin-copr From fad34c4a103c2caebe953f8a67545c9a6d4d6eb5 Mon Sep 17 00:00:00 2001 From: Bruno Goncalves Date: Feb 19 2018 14:37:34 +0000 Subject: [PATCH 3/3] include common role --- diff --git a/roles/standard-test-beakerlib/tasks/main.yml b/roles/standard-test-beakerlib/tasks/main.yml index 2172110..0ab3685 100644 --- a/roles/standard-test-beakerlib/tasks/main.yml +++ b/roles/standard-test-beakerlib/tasks/main.yml @@ -2,8 +2,9 @@ - delegate_to: "{{ test_runner_inventory_name }}" block: - - include_tasks: >- - ../../str-common/tasks/pkgs-{{hostvars[test_runner_inventory_name]['ansible_pkg_mgr']}}.yml + - include_role: + name: str-common + tasks_from: pkgs-{{hostvars[test_runner_inventory_name]['ansible_pkg_mgr']}}.yml vars: copr_repos: "bpeck/restraint" name: "Enable copr repositories"