Browse Source

Remove yum / dnf duplication

Scott Dodson 9 years ago
parent
commit
b1d30491f1
36 changed files with 107 additions and 316 deletions
  1. 47 0
      docs/best_practices_guide.adoc
  2. 2 36
      playbooks/adhoc/uninstall.yml
  3. 2 2
      playbooks/aws/ansible-tower/launch.yml
  4. 2 2
      playbooks/common/openshift-cluster/upgrades/v3_0_minor/upgrade.yml
  5. 7 13
      playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml
  6. 1 1
      playbooks/common/openshift-master/config.yml
  7. 1 10
      roles/ansible/tasks/main.yml
  8. 1 1
      roles/ansible_tower/tasks/main.yaml
  9. 1 1
      roles/ansible_tower_cli/tasks/main.yml
  10. 1 15
      roles/cockpit/tasks/main.yml
  11. 1 9
      roles/copr_cli/tasks/main.yml
  12. 2 7
      roles/docker/tasks/main.yml
  13. 1 6
      roles/etcd/tasks/main.yml
  14. 1 7
      roles/flannel/tasks/main.yml
  15. 1 10
      roles/fluentd_master/tasks/main.yml
  16. 1 10
      roles/fluentd_node/tasks/main.yml
  17. 1 10
      roles/haproxy/tasks/main.yml
  18. 1 6
      roles/kube_nfs_volumes/tasks/main.yml
  19. 2 7
      roles/kube_nfs_volumes/tasks/nfs.yml
  20. 1 1
      roles/nickhammond.logrotate/tasks/main.yml
  21. 1 13
      roles/openshift_ansible_inventory/tasks/main.yml
  22. 1 6
      roles/openshift_expand_partition/tasks/main.yml
  23. 1 10
      roles/openshift_facts/tasks/main.yml
  24. 4 16
      roles/openshift_master/tasks/main.yml
  25. 1 8
      roles/openshift_master_ca/tasks/main.yml
  26. 3 16
      roles/openshift_node/tasks/main.yml
  27. 1 10
      roles/openshift_node/tasks/storage_plugins/ceph.yml
  28. 1 10
      roles/openshift_node/tasks/storage_plugins/glusterfs.yml
  29. 2 5
      roles/openshift_repos/handlers/main.yml
  30. 8 17
      roles/openshift_repos/tasks/main.yaml
  31. 2 7
      roles/openshift_storage_nfs_lvm/tasks/nfs.yml
  32. 1 10
      roles/os_env_extras/tasks/main.yaml
  33. 1 11
      roles/os_firewall/tasks/firewall/firewalld.yml
  34. 1 14
      roles/os_firewall/tasks/firewall/iptables.yml
  35. 1 6
      roles/os_update_latest/tasks/main.yml
  36. 1 3
      roles/tito/tasks/main.yml

+ 47 - 0
docs/best_practices_guide.adoc

@@ -466,3 +466,50 @@ If you want to use default with variables that evaluate to false you have to set
 In other words, normally the `default` filter will only replace the value if it's undefined. By setting the second parameter to `true`, it will also replace the value if it defaults to a false value in python, so None, empty list, empty string, etc.
 In other words, normally the `default` filter will only replace the value if it's undefined. By setting the second parameter to `true`, it will also replace the value if it defaults to a false value in python, so None, empty list, empty string, etc.
 
 
 This is almost always more desirable than an empty list, string, etc.
 This is almost always more desirable than an empty list, string, etc.
+
+=== Yum and DNF
+'''
+[cols="2v,v"]
+|===
+| **Rule**
+| Package installation MUST use ansible action module to abstract away dnf/yum.
+| Package installation MUST use name= and state=present rather than pkg= and state=installed respectively.
+|===
+[cols="2v,v"]
+|===
+| **Rule**
+| Package installation MUST use name= and state=present rather than pkg= and state=installed respectively.
+|===
+
+This is done primarily because if you're registering the result of the
+installation and you have two conditional tasks based on whether or not yum or
+dnf are in use you'll end up inadvertently overwriting the value. It also
+reduces duplication. name= and state=present are common between dnf and yum
+modules.
+
+.Bad:
+[source,yaml]
+----
+---
+# tasks.yml
+- name: Install etcd (for etcdctl)
+  yum: name=etcd state=latest"
+  when: "ansible_pkg_mgr == yum"
+  register: install_result
+
+- name: Install etcd (for etcdctl)
+  dnf: name=etcd state=latest"
+  when: "ansible_pkg_mgr == dnf"
+  register: install_result
+----
+
+
+.Good:
+[source,yaml]
+----
+---
+# tasks.yml
+- name: Install etcd (for etcdctl)
+  action: "{{ ansible_pkg_mgr }} name=etcd state=latest"
+  register: install_result
+  ----

+ 2 - 36
playbooks/adhoc/uninstall.yml

@@ -47,42 +47,8 @@
         - origin-node
         - origin-node
         - pcsd
         - pcsd
 
 
-    - yum: name={{ item }} state=absent
-      when: ansible_pkg_mgr == "yum" and not is_atomic | bool
-      with_items:
-        - atomic-enterprise
-        - atomic-enterprise-master
-        - atomic-enterprise-node
-        - atomic-enterprise-sdn-ovs
-        - atomic-openshift
-        - atomic-openshift-clients
-        - atomic-openshift-master
-        - atomic-openshift-node
-        - atomic-openshift-sdn-ovs
-        - corosync
-        - etcd
-        - openshift
-        - openshift-master
-        - openshift-node
-        - openshift-sdn
-        - openshift-sdn-ovs
-        - openvswitch
-        - origin
-        - origin-clients
-        - origin-master
-        - origin-node
-        - origin-sdn-ovs
-        - pacemaker
-        - pcs
-        - tuned-profiles-atomic-enterprise-node
-        - tuned-profiles-atomic-openshift-node
-        - tuned-profiles-openshift-node
-        - tuned-profiles-origin-node
-
-    - user: name=hacluster state=absent
-
-    - dnf: name={{ item }} state=absent
-      when: ansible_pkg_mgr == "dnf" and not is_atomic | bool
+    - action: "{{ ansible_pkg_mgr }} name={{ item }} state=absent"
+      when: not is_atomic | bool
       with_items:
       with_items:
         - atomic-enterprise
         - atomic-enterprise
         - atomic-enterprise-master
         - atomic-enterprise-master

+ 2 - 2
playbooks/aws/ansible-tower/launch.yml

@@ -71,8 +71,8 @@
 
 
   tasks:
   tasks:
 
 
-    - name: Yum update
-      yum: name=* state=latest
+    - name: Update All Things
+      action: "{{ ansible_pkg_mgr }} name=* state=latest"
 
 
 # Apply the configs, seprate so that just the configs can be run by themselves
 # Apply the configs, seprate so that just the configs can be run by themselves
 - include: config.yml
 - include: config.yml

+ 2 - 2
playbooks/common/openshift-cluster/upgrades/v3_0_minor/upgrade.yml

@@ -11,7 +11,7 @@
     openshift_version: "{{ openshift_pkg_version | default('') }}"
     openshift_version: "{{ openshift_pkg_version | default('') }}"
   tasks:
   tasks:
     - name: Upgrade master packages
     - name: Upgrade master packages
-      yum: pkg={{ openshift.common.service_type }}-master{{ openshift_version }} state=latest
+      action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-master{{ openshift_version }} state=latest"
     - name: Restart master services
     - name: Restart master services
       service: name="{{ openshift.common.service_type}}-master" state=restarted
       service: name="{{ openshift.common.service_type}}-master" state=restarted
 
 
@@ -21,7 +21,7 @@
     openshift_version: "{{ openshift_pkg_version | default('') }}"
     openshift_version: "{{ openshift_pkg_version | default('') }}"
   tasks:
   tasks:
     - name: Upgrade node packages
     - name: Upgrade node packages
-      yum: pkg={{ openshift.common.service_type }}-node{{ openshift_version }} state=latest
+      action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version }} state=latest"
     - name: Restart node services
     - name: Restart node services
       service: name="{{ openshift.common.service_type }}-node" state=restarted
       service: name="{{ openshift.common.service_type }}-node" state=restarted
 
 

+ 7 - 13
playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml

@@ -54,8 +54,8 @@
 - name: Verify upgrade can proceed
 - name: Verify upgrade can proceed
   hosts: oo_masters_to_config:oo_nodes_to_config
   hosts: oo_masters_to_config:oo_nodes_to_config
   tasks:
   tasks:
-  - name: Clean yum cache
-    command: yum clean all
+  - name: Clean package cache
+    command: "{{ ansible_pkg_mgr }} clean all"
 
 
   - set_fact:
   - set_fact:
       g_new_service_name: "{{ 'origin' if deployment_type =='origin' else 'atomic-openshift' }}"
       g_new_service_name: "{{ 'origin' if deployment_type =='origin' else 'atomic-openshift' }}"
@@ -149,9 +149,7 @@
     when: (embedded_etcd | bool) and (etcd_disk_usage.stdout|int > avail_disk.stdout|int)
     when: (embedded_etcd | bool) and (etcd_disk_usage.stdout|int > avail_disk.stdout|int)
 
 
   - name: Install etcd (for etcdctl)
   - name: Install etcd (for etcdctl)
-    yum:
-      pkg: etcd
-      state: latest
+    action: "{{ ansible_pkg_mgr }} name=etcd state=latest"
 
 
   - name: Generate etcd backup
   - name: Generate etcd backup
     command: >
     command: >
@@ -222,17 +220,13 @@
     openshift_version: "{{ openshift_pkg_version | default('') }}"
     openshift_version: "{{ openshift_pkg_version | default('') }}"
   tasks:
   tasks:
   - name: Upgrade to latest available kernel
   - name: Upgrade to latest available kernel
-    yum:
-      pkg: kernel
-      state: latest
+    action: "{{ ansible_pkg_mgr}} name=kernel state=latest"
 
 
   - name: Upgrade master packages
   - name: Upgrade master packages
-    command: yum update -y {{ openshift.common.service_type }}-master{{ openshift_version }}
+    command: "{{ ansible_pkg_mgr}} update -y {{ openshift.common.service_type }}-master{{ openshift_version }}"
 
 
   - name: Ensure python-yaml present for config upgrade
   - name: Ensure python-yaml present for config upgrade
-    yum:
-      pkg: PyYAML
-      state: installed
+    action: "{{ ansible_pkg_mgr }} name=PyYAML state=present"
 
 
   - name: Upgrade master configuration
   - name: Upgrade master configuration
     openshift_upgrade_config:
     openshift_upgrade_config:
@@ -380,7 +374,7 @@
   - openshift_facts
   - openshift_facts
   tasks:
   tasks:
   - name: Upgrade node packages
   - name: Upgrade node packages
-    command: yum update -y {{ openshift.common.service_type }}-node{{ openshift_version }}
+    command: "{{ ansible_pkg_mgr }} update -y {{ openshift.common.service_type }}-node{{ openshift_version }}"
 
 
   - name: Restart node service
   - name: Restart node service
     service: name="{{ openshift.common.service_type }}-node" state=restarted
     service: name="{{ openshift.common.service_type }}-node" state=restarted

+ 1 - 1
playbooks/common/openshift-master/config.yml

@@ -245,7 +245,7 @@
       msg: "openshift_master_session_auth_secrets and openshift_master_encryption_secrets must be equal length"
       msg: "openshift_master_session_auth_secrets and openshift_master_encryption_secrets must be equal length"
     when: (openshift_master_session_auth_secrets is defined and openshift_master_session_encryption_secrets is defined) and (openshift_master_session_auth_secrets | length != openshift_master_session_encryption_secrets | length)
     when: (openshift_master_session_auth_secrets is defined and openshift_master_session_encryption_secrets is defined) and (openshift_master_session_auth_secrets | length != openshift_master_session_encryption_secrets | length)
   - name: Install OpenSSL package
   - name: Install OpenSSL package
-    action: "{{ansible_pkg_mgr}} pkg=openssl state=present"
+    action: "{{ ansible_pkg_mgr }} name=openssl state=present"
   - name: Generate session authentication key
   - name: Generate session authentication key
     command: /usr/bin/openssl rand -base64 24
     command: /usr/bin/openssl rand -base64 24
     register: session_auth_output
     register: session_auth_output

+ 1 - 10
roles/ansible/tasks/main.yml

@@ -2,16 +2,7 @@
 # Install ansible client
 # Install ansible client
 
 
 - name: Install Ansible
 - name: Install Ansible
-  yum:
-    pkg: ansible
-    state: installed
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install Ansible
-  dnf:
-    pkg: ansible
-    state: installed
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=ansible state=present"
 
 
 - include: config.yml
 - include: config.yml
   vars:
   vars:

+ 1 - 1
roles/ansible_tower/tasks/main.yaml

@@ -1,6 +1,6 @@
 ---
 ---
 - name: install some useful packages
 - name: install some useful packages
-  yum: name={{ item }}
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
   with_items:
   with_items:
   - git
   - git
   - python-pip
   - python-pip

+ 1 - 1
roles/ansible_tower_cli/tasks/main.yml

@@ -1,6 +1,6 @@
 ---
 ---
 - name: Install python-ansible-tower-cli
 - name: Install python-ansible-tower-cli
-  yum: name=python-ansible-tower-cli
+  action: "{{ ansible_pkg_mgr }} name=python-ansible-tower-cli state=present"
 
 
 - template:
 - template:
     src: tower_cli.cfg.j2
     src: tower_cli.cfg.j2

+ 1 - 15
roles/cockpit/tasks/main.yml

@@ -1,25 +1,11 @@
 ---
 ---
 - name: Install cockpit-ws
 - name: Install cockpit-ws
-  yum:
-    name: "{{ item }}"
-    state: present
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
   with_items:
   with_items:
     - cockpit-ws
     - cockpit-ws
     - cockpit-shell
     - cockpit-shell
     - cockpit-bridge
     - cockpit-bridge
     - "{{ cockpit_plugins }}"
     - "{{ cockpit_plugins }}"
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install cockpit-ws
-  dnf:
-    name: "{{ item }}"
-    state: present
-  with_items:
-    - cockpit-ws
-    - cockpit-shell
-    - cockpit-bridge
-    - "{{ cockpit_plugins }}"
-  when: ansible_pkg_mgr == "dnf"
 
 
 - name: Enable cockpit-ws
 - name: Enable cockpit-ws
   service:
   service:

+ 1 - 9
roles/copr_cli/tasks/main.yml

@@ -1,10 +1,2 @@
 ---
 ---
-- yum:
-    name: copr-cli
-    state: present
-  when: ansible_pkg_mgr == "yum"
-
-- dnf:
-    name: copr-cli
-    state: present
-  when: ansible_pkg_mgr == "dnf"
+- action: "{{ ansible_pkg_mgr }} name=copr-cli state=present"

+ 2 - 7
roles/docker/tasks/main.yml

@@ -1,13 +1,8 @@
 ---
 ---
 # tasks file for docker
 # tasks file for docker
 - name: Install docker
 - name: Install docker
-  yum: pkg=docker
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install docker
-  dnf: pkg=docker
-  when: ansible_pkg_mgr == "dnf"
-
+  action: "{{ ansible_pkg_mgr }} name=docker state=present"
+  
 - name: enable and start the docker service
 - name: enable and start the docker service
   service: name=docker enabled=yes state=started
   service: name=docker enabled=yes state=started
 
 

+ 1 - 6
roles/etcd/tasks/main.yml

@@ -8,12 +8,7 @@
   when: "'ipv4' not in hostvars[inventory_hostname]['ansible_' ~ etcd_interface] or 'address' not in hostvars[inventory_hostname]['ansible_' ~ etcd_interface].ipv4"
   when: "'ipv4' not in hostvars[inventory_hostname]['ansible_' ~ etcd_interface] or 'address' not in hostvars[inventory_hostname]['ansible_' ~ etcd_interface].ipv4"
 
 
 - name: Install etcd
 - name: Install etcd
-  yum: pkg=etcd-2.* state=present
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install etcd
-  dnf: pkg=etcd* state=present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=etcd-2.* state=present"
 
 
 - name: Validate permissions on the config dir
 - name: Validate permissions on the config dir
   file:
   file:

+ 1 - 7
roles/flannel/tasks/main.yml

@@ -1,13 +1,7 @@
 ---
 ---
 - name: Install flannel
 - name: Install flannel
   sudo: true
   sudo: true
-  yum: pkg=flannel state=present
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install flannel
-  sudo: true
-  dnf: pkg=flannel state=present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=flannel state=present"
 
 
 - name: Set flannel etcd url
 - name: Set flannel etcd url
   sudo: true
   sudo: true

+ 1 - 10
roles/fluentd_master/tasks/main.yml

@@ -1,16 +1,7 @@
 ---
 ---
 # TODO: Update fluentd install and configuration when packaging is complete
 # TODO: Update fluentd install and configuration when packaging is complete
 - name: download and install td-agent
 - name: download and install td-agent
-  yum:
-    name: 'http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm'
-    state: present
-  when: ansible_pkg_mgr == "yum"
-
-- name: download and install td-agent
-  dnf:
-    name: 'http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm'
-    state: present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name='http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm' state=present"
 
 
 - name: Verify fluentd plugin installed
 - name: Verify fluentd plugin installed
   command: '/opt/td-agent/embedded/bin/gem query -i fluent-plugin-kubernetes'
   command: '/opt/td-agent/embedded/bin/gem query -i fluent-plugin-kubernetes'

+ 1 - 10
roles/fluentd_node/tasks/main.yml

@@ -1,16 +1,7 @@
 ---
 ---
 # TODO: Update fluentd install and configuration when packaging is complete
 # TODO: Update fluentd install and configuration when packaging is complete
 - name: download and install td-agent
 - name: download and install td-agent
-  yum:
-    name: 'http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm'
-    state: present
-  when: ansible_pkg_mgr == "yum"
-
-- name: download and install td-agent
-  dnf:
-    name: 'http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm'
-    state: present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name='http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm' state=present"
 
 
 - name: Verify fluentd plugin installed
 - name: Verify fluentd plugin installed
   command: '/opt/td-agent/embedded/bin/gem query -i fluent-plugin-kubernetes'
   command: '/opt/td-agent/embedded/bin/gem query -i fluent-plugin-kubernetes'

+ 1 - 10
roles/haproxy/tasks/main.yml

@@ -1,15 +1,6 @@
 ---
 ---
 - name: Install haproxy
 - name: Install haproxy
-  yum:
-    pkg: haproxy
-    state: present
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install haproxy
-  dnf:
-    pkg: haproxy
-    state: present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=haproxy state=present"
 
 
 - name: Configure haproxy
 - name: Configure haproxy
   template:
   template:

+ 1 - 6
roles/kube_nfs_volumes/tasks/main.yml

@@ -1,11 +1,6 @@
 ---
 ---
 - name: Install pyparted (RedHat/Fedora)
 - name: Install pyparted (RedHat/Fedora)
-  yum: name=pyparted,python-httplib2 state=present
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install pyparted (RedHat/Fedora)
-  dnf: name=pyparted,python-httplib2 state=present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=pyparted,python-httplib2 state=present"
 
 
 - name: partition the drives
 - name: partition the drives
   partitionpool: disks={{ disks }} force={{ force }} sizes={{ sizes }}
   partitionpool: disks={{ disks }} force={{ force }} sizes={{ sizes }}

+ 2 - 7
roles/kube_nfs_volumes/tasks/nfs.yml

@@ -1,11 +1,6 @@
 ---
 ---
-- name: Install NFS server on Fedora/Red Hat
-  yum: name=nfs-utils state=present
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install NFS server on Fedora/Red Hat
-  dnf: name=nfs-utils state=present
-  when: ansible_pkg_mgr == "dnf"
+- name: Install NFS server
+  action: "{{ ansible_pkg_mgr }} name=nfs-utils state=present"
 
 
 - name: Start rpcbind on Fedora/Red Hat
 - name: Start rpcbind on Fedora/Red Hat
   service: name=rpcbind state=started enabled=yes
   service: name=rpcbind state=started enabled=yes

+ 1 - 1
roles/nickhammond.logrotate/tasks/main.yml

@@ -1,6 +1,6 @@
 ---
 ---
 - name: nickhammond.logrotate | Install logrotate
 - name: nickhammond.logrotate | Install logrotate
-  action: "{{ansible_pkg_mgr}} pkg=logrotate state=present"
+  action: "{{ ansible_pkg_mgr }} name=logrotate state=present"
 
 
 - name: nickhammond.logrotate | Setup logrotate.d scripts
 - name: nickhammond.logrotate | Setup logrotate.d scripts
   template:
   template:

+ 1 - 13
roles/openshift_ansible_inventory/tasks/main.yml

@@ -1,17 +1,5 @@
 ---
 ---
-- yum:
-    name: "{{ item }}"
-    state: present
-  when: ansible_pkg_mgr == "yum"
-  with_items:
-  - openshift-ansible-inventory
-  - openshift-ansible-inventory-aws
-  - openshift-ansible-inventory-gce
-
-- dnf:
-    name: "{{ item }}"
-    state: present
-  when: ansible_pkg_mgr == "dnf"
+- action: "{{ ansible_pkg_mgr }} name={{ item}} state=present"
   with_items:
   with_items:
   - openshift-ansible-inventory
   - openshift-ansible-inventory
   - openshift-ansible-inventory-aws
   - openshift-ansible-inventory-aws

+ 1 - 6
roles/openshift_expand_partition/tasks/main.yml

@@ -1,11 +1,6 @@
 ---
 ---
 - name: Ensure growpart is installed
 - name: Ensure growpart is installed
-  yum: pkg=cloud-utils-growpart state=present
-  when: ansible_pkg_mgr == "yum"
-
-- name: Ensure growpart is installed
-  dnf: pkg=cloud-utils-growpart state=present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=cloud-utils-growpart state=present"
 
 
 - name: Grow the partitions
 - name: Grow the partitions
   command: "growpart {{oep_drive}} {{oep_partition}}"
   command: "growpart {{oep_drive}} {{oep_partition}}"

+ 1 - 10
roles/openshift_facts/tasks/main.yml

@@ -7,16 +7,7 @@
     - ansible_version | version_compare('1.9.0.1', 'ne')
     - ansible_version | version_compare('1.9.0.1', 'ne')
 
 
 - name: Ensure PyYaml is installed
 - name: Ensure PyYaml is installed
-  yum: pkg={{ item }} state=installed
-  when: ansible_pkg_mgr == "yum"
-  with_items:
-    - PyYAML
-
-- name: Ensure PyYaml is installed
-  dnf: pkg={{ item }} state=installed
-  when: ansible_pkg_mgr == "dnf"
-  with_items:
-    - PyYAML
+  action: "{{ ansible_pkg_mgr }} name=PyYAML state=present"
 
 
 - name: Gather Cluster facts
 - name: Gather Cluster facts
   openshift_facts:
   openshift_facts:

+ 4 - 16
roles/openshift_master/tasks/main.yml

@@ -78,14 +78,7 @@
       controller_lease_ttl: "{{ osm_controller_lease_ttl | default(None) }}"
       controller_lease_ttl: "{{ osm_controller_lease_ttl | default(None) }}"
 
 
 - name: Install Master package
 - name: Install Master package
-  yum: pkg={{ openshift.common.service_type }}-master{{ openshift_version  }} state=present
-  when: ansible_pkg_mgr == "yum"
-  register: install_result
-
-- name: Install Master package
-  dnf: pkg={{ openshift.common.service_type }}-master{{ openshift_version  }} state=present
-  when: ansible_pkg_mgr == "dnf"
-  register: install_result
+  action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-master{{ openshift_version  }} state=present"
 
 
 - name: Re-gather package dependent master facts
 - name: Re-gather package dependent master facts
   openshift_facts:
   openshift_facts:
@@ -117,13 +110,8 @@
   - restart master controllers
   - restart master controllers
 
 
 - name: Install httpd-tools if needed
 - name: Install httpd-tools if needed
-  yum: pkg=httpd-tools state=present
-  when: (ansible_pkg_mgr == "yum") and (item.kind == 'HTPasswdPasswordIdentityProvider')
-  with_items: openshift.master.identity_providers
-
-- name: Install httpd-tools if needed
-  dnf: pkg=httpd-tools state=present
-  when: (ansible_pkg_mgr == "dnf") and (item.kind == 'HTPasswdPasswordIdentityProvider')
+  action: "{{ ansible_pkg_mgr }} name=httpd-tools state=present"
+  when: (item.kind == 'HTPasswdPasswordIdentityProvider')
   with_items: openshift.master.identity_providers
   with_items: openshift.master.identity_providers
 
 
 - name: Ensure htpasswd directory exists
 - name: Ensure htpasswd directory exists
@@ -267,7 +255,7 @@
   when: openshift_master_ha | bool and openshift.master.cluster_method == 'native'
   when: openshift_master_ha | bool and openshift.master.cluster_method == 'native'
 
 
 - name: Install cluster packages
 - name: Install cluster packages
-  action: "{{ansible_pkg_mgr}} pkg=pcs state=present"
+  action: "{{ ansible_pkg_mgr }} name=pcs state=present"
   when: openshift_master_ha | bool and openshift.master.cluster_method == 'pacemaker'
   when: openshift_master_ha | bool and openshift.master.cluster_method == 'pacemaker'
   register: install_result
   register: install_result
 
 

+ 1 - 8
roles/openshift_master_ca/tasks/main.yml

@@ -1,13 +1,6 @@
 ---
 ---
 - name: Install the base package for admin tooling
 - name: Install the base package for admin tooling
-  yum: pkg={{ openshift.common.service_type }}{{ openshift_version  }} state=present
-  when: ansible_pkg_mgr == "yum"
-  register: install_result
-
-- name: Install the base package for admin tooling
-  dnf: pkg={{ openshift.common.service_type }}{{ openshift_version  }} state=present
-  when: ansible_pkg_mgr == "dnf"
-  register: install_result
+  action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version  }} state=present"
 
 
 - name: Reload generated facts
 - name: Reload generated facts
   openshift_facts:
   openshift_facts:

+ 3 - 16
roles/openshift_node/tasks/main.yml

@@ -37,24 +37,11 @@
 # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
 # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
 # problems because the rpms don't pin the version properly.
 # problems because the rpms don't pin the version properly.
 - name: Install Node package
 - name: Install Node package
-  yum: pkg={{ openshift.common.service_type }}-node{{ openshift_version  }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version  }} state=present
-  when: ansible_pkg_mgr == "yum"
-  register: node_install_result
-
-- name: Install Node package
-  dnf: pkg={{ openshift.common.service_type }}-node{{ openshift_version  }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version  }} state=present
-  when: ansible_pkg_mgr == "dnf"
-  register: node_install_result
-
-- name: Install sdn-ovs package
-  yum: pkg={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present
-  register: sdn_install_result
-  when: ansible_pkg_mgr == "yum" and openshift.common.use_openshift_sdn
+  action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version  }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version  }} state=present"
 
 
 - name: Install sdn-ovs package
 - name: Install sdn-ovs package
-  dnf: pkg={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present
-  register: sdn_install_result
-  when: ansible_pkg_mgr == "dnf" and openshift.common.use_openshift_sdn
+  action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present"
+  when: openshift.common.use_openshift_sdn
 
 
 # TODO: add the validate parameter when there is a validation command to run
 # TODO: add the validate parameter when there is a validation command to run
 - name: Create the Node config
 - name: Create the Node config

+ 1 - 10
roles/openshift_node/tasks/storage_plugins/ceph.yml

@@ -1,12 +1,3 @@
 ---
 ---
 - name: Install Ceph storage plugin dependencies
 - name: Install Ceph storage plugin dependencies
-  yum:
-    pkg: ceph-common
-    state: installed
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install Ceph storage plugin dependencies
-  dnf:
-    pkg: ceph-common
-    state: installed
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=ceph-common state=present"

+ 1 - 10
roles/openshift_node/tasks/storage_plugins/glusterfs.yml

@@ -1,15 +1,6 @@
 ---
 ---
 - name: Install GlusterFS storage plugin dependencies
 - name: Install GlusterFS storage plugin dependencies
-  yum:
-    pkg: glusterfs-fuse
-    state: installed
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install GlusterFS storage plugin dependencies
-  dnf:
-    pkg: glusterfs-fuse
-    state: installed
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=glusterfs-fuse state=present"
 
 
 - name: Set sebooleans to allow gluster storage plugin access from containers
 - name: Set sebooleans to allow gluster storage plugin access from containers
   seboolean:
   seboolean:

+ 2 - 5
roles/openshift_repos/handlers/main.yml

@@ -1,6 +1,3 @@
 ---
 ---
-- name: refresh yum cache
-  command: yum clean all
-
-- name: refresh dnf cache
-  command: dnf clean all
+- name: refresh cache
+  command: "{{ ansible_pkg_mgr }} clean all"

+ 8 - 17
roles/openshift_repos/tasks/main.yaml

@@ -11,30 +11,21 @@
     that: openshift.common.deployment_type in known_openshift_deployment_types
     that: openshift.common.deployment_type in known_openshift_deployment_types
 
 
 - name: Ensure libselinux-python is installed
 - name: Ensure libselinux-python is installed
-  yum:
-    pkg: libselinux-python
-    state: present
-  when: ansible_pkg_mgr == "yum"
-
-- name: Ensure libselinux-python is installed
-  dnf:
-    pkg: libselinux-python
-    state: present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=libselinux-python state=present"
 
 
 - name: Create any additional repos that are defined
 - name: Create any additional repos that are defined
   template:
   template:
     src: yum_repo.j2
     src: yum_repo.j2
     dest: /etc/yum.repos.d/openshift_additional.repo
     dest: /etc/yum.repos.d/openshift_additional.repo
   when: openshift_additional_repos | length > 0
   when: openshift_additional_repos | length > 0
-  notify: refresh yum cache
+  notify: refresh cache
 
 
 - name: Remove the additional repos if no longer defined
 - name: Remove the additional repos if no longer defined
   file:
   file:
     dest: /etc/yum.repos.d/openshift_additional.repo
     dest: /etc/yum.repos.d/openshift_additional.repo
     state: absent
     state: absent
   when: openshift_additional_repos | length == 0
   when: openshift_additional_repos | length == 0
-  notify: refresh yum cache
+  notify: refresh cache
 
 
 - name: Remove any yum repo files for other deployment types RHEL/CentOS
 - name: Remove any yum repo files for other deployment types RHEL/CentOS
   file:
   file:
@@ -44,7 +35,7 @@
   - '*/repos/*'
   - '*/repos/*'
   when: not (item | search("/files/" ~ openshift_deployment_type ~ "/repos")) and
   when: not (item | search("/files/" ~ openshift_deployment_type ~ "/repos")) and
         (ansible_os_family == "RedHat" and ansible_distribution != "Fedora")
         (ansible_os_family == "RedHat" and ansible_distribution != "Fedora")
-  notify: refresh yum cache
+  notify: refresh cache
 
 
 - name: Remove any yum repo files for other deployment types Fedora
 - name: Remove any yum repo files for other deployment types Fedora
   file:
   file:
@@ -54,24 +45,24 @@
   - '*/repos/*'
   - '*/repos/*'
   when: not (item | search("/files/fedora-" ~ openshift_deployment_type ~ "/repos")) and
   when: not (item | search("/files/fedora-" ~ openshift_deployment_type ~ "/repos")) and
         (ansible_distribution == "Fedora")
         (ansible_distribution == "Fedora")
-  notify: refresh dnf cache
+  notify: refresh cache
 
 
 - name: Configure gpg keys if needed
 - name: Configure gpg keys if needed
   copy: src={{ item }} dest=/etc/pki/rpm-gpg/
   copy: src={{ item }} dest=/etc/pki/rpm-gpg/
   with_fileglob:
   with_fileglob:
   - "{{ openshift_deployment_type }}/gpg_keys/*"
   - "{{ openshift_deployment_type }}/gpg_keys/*"
-  notify: refresh yum cache
+  notify: refresh cache
 
 
 - name: Configure yum repositories RHEL/CentOS
 - name: Configure yum repositories RHEL/CentOS
   copy: src={{ item }} dest=/etc/yum.repos.d/
   copy: src={{ item }} dest=/etc/yum.repos.d/
   with_fileglob:
   with_fileglob:
   - "{{ openshift_deployment_type }}/repos/*"
   - "{{ openshift_deployment_type }}/repos/*"
-  notify: refresh yum cache
+  notify: refresh cache
   when: (ansible_os_family == "RedHat" and ansible_distribution != "Fedora")
   when: (ansible_os_family == "RedHat" and ansible_distribution != "Fedora")
 
 
 - name: Configure yum repositories Fedora
 - name: Configure yum repositories Fedora
   copy: src={{ item }} dest=/etc/yum.repos.d/
   copy: src={{ item }} dest=/etc/yum.repos.d/
   with_fileglob:
   with_fileglob:
   - "fedora-{{ openshift_deployment_type }}/repos/*"
   - "fedora-{{ openshift_deployment_type }}/repos/*"
-  notify: refresh dnf cache
+  notify: refresh cache
   when: (ansible_distribution == "Fedora")
   when: (ansible_distribution == "Fedora")

+ 2 - 7
roles/openshift_storage_nfs_lvm/tasks/nfs.yml

@@ -1,12 +1,7 @@
 ---
 ---
 - name: Install NFS server
 - name: Install NFS server
-  yum: name=nfs-utils state=present
-  when: ansible_pkg_mgr == "yum"
-
-- name: Install NFS server
-  dnf: name=nfs-utils state=present
-  when: ansible_pkg_mgr == "dnf"
-
+  action: "{{ ansible_pkg_mgr }} name=nfs-utils state=present"
+  
 - name: Start rpcbind
 - name: Start rpcbind
   service: name=rpcbind state=started enabled=yes
   service: name=rpcbind state=started enabled=yes
 
 

+ 1 - 10
roles/os_env_extras/tasks/main.yaml

@@ -12,13 +12,4 @@
     dest: /root/.vimrc
     dest: /root/.vimrc
 
 
 - name: Bash Completion
 - name: Bash Completion
-  yum:
-    pkg: bash-completion
-    state: installed
-  when: ansible_pkg_mgr == "yum"
-
-- name: Bash Completion
-  dnf:
-    pkg: bash-completion
-    state: installed
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=bash-completion state=present"

+ 1 - 11
roles/os_firewall/tasks/firewall/firewalld.yml

@@ -1,16 +1,6 @@
 ---
 ---
 - name: Install firewalld packages
 - name: Install firewalld packages
-  yum:
-    name: firewalld
-    state: present
-  when: ansible_pkg_mgr == "yum"
-  register: install_result
-
-- name: Install firewalld packages
-  dnf:
-    name: firewalld
-    state: present
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=firewalld state=present"
   register: install_result
   register: install_result
 
 
 - name: Check if iptables-services is installed
 - name: Check if iptables-services is installed

+ 1 - 14
roles/os_firewall/tasks/firewall/iptables.yml

@@ -1,22 +1,9 @@
 ---
 ---
 - name: Install iptables packages
 - name: Install iptables packages
-  yum:
-    name: "{{ item }}"
-    state: present
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
   with_items:
   with_items:
   - iptables
   - iptables
   - iptables-services
   - iptables-services
-  when: ansible_pkg_mgr == "yum"
-  register: install_result
-
-- name: Install iptables packages
-  dnf:
-    name: "{{ item }}"
-    state: present
-  with_items:
-  - iptables
-  - iptables-services
-  when: ansible_pkg_mgr == "dnf"
   register: install_result
   register: install_result
 
 
 - name: Check if firewalld is installed
 - name: Check if firewalld is installed

+ 1 - 6
roles/os_update_latest/tasks/main.yml

@@ -1,8 +1,3 @@
 ---
 ---
 - name: Update all packages
 - name: Update all packages
-  yum: name=* state=latest
-  when: ansible_pkg_mgr == "yum"
-
-- name: Update all packages
-  dnf: name=* state=latest
-  when: ansible_pkg_mgr == "dnf"
+  action: "{{ ansible_pkg_mgr }} name=* state=latest"

+ 1 - 3
roles/tito/tasks/main.yml

@@ -1,4 +1,2 @@
 ---
 ---
-- yum:
-    name: tito
-    state: present
+- action: "{{ ansible_pkg_mgr }} name=tito state=present"