#127 move enable copr to pkg roles
Closed 6 years ago by bgoncalv. Opened 6 years ago by bgoncalv.
bgoncalv/standard-test-roles issue99  into  master

@@ -2,17 +2,12 @@ 

  

  - 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_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"

  

    - name: Install the beakerlib requirements

      package: name={{item}} state=present

@@ -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:

@@ -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,4 +24,13 @@ 

      with_items:

          - "{{ pkgs_debuginfo_req }}"

    when:

-     - pkgs_debuginfo_req

+     - pkgs_debuginfo_req is defined

+ 

+ - 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

@@ -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,4 +22,13 @@ 

      with_items:

          - "{{ pkgs_debuginfo_req }}"

    when:

-     - pkgs_debuginfo_req

+     - pkgs_debuginfo_req is defined

+ 

+ - 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