From 07b2f06a82226f78a14cd8035a3b2aa69fd51dba Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Wed, 18 Apr 2018 15:56:59 +0100
Subject: [PATCH] Support Ansible 2.5

Raises the maximum Ansible version in requirements.txt to Ansible 2.5.x
for both kayobe and kolla ansible.

Also removes the hack to use a patched parted module for ceph block
device management, as Ansible 2.4 contains the required fix.

Change-Id: I0d2f564eb1ddb63b07829d6f0d918af26887db97
Story: 2001649
Task: 6668
---
 ansible/ceph-block-devices.yml                       |  3 +--
 ansible/roles/kolla-ansible/tasks/install.yml        |  1 +
 .../kolla-ansible/templates/requirements.txt.j2      |  2 +-
 ansible/roles/kolla-ceph/tasks/config.yml            | 11 +++++------
 .../kolla-ceph/tests/test-bootstrapped-journal.yml   | 12 ++++--------
 ansible/roles/kolla-ceph/tests/test-data-journal.yml | 12 ++++--------
 ansible/roles/kolla-ceph/tests/test-journal.yml      |  8 ++------
 ansible/roles/kolla-ceph/tests/test-no-journal.yml   |  6 +-----
 releasenotes/notes/ansible-2.5-785e3c764f450d09.yaml |  4 ++++
 requirements.txt                                     |  2 +-
 requirements.yml                                     |  1 -
 11 files changed, 24 insertions(+), 38 deletions(-)
 create mode 100644 releasenotes/notes/ansible-2.5-785e3c764f450d09.yaml

diff --git a/ansible/ceph-block-devices.yml b/ansible/ceph-block-devices.yml
index 4912f605..88c3a4e1 100644
--- a/ansible/ceph-block-devices.yml
+++ b/ansible/ceph-block-devices.yml
@@ -1,9 +1,8 @@
 ---
 - name: Ensure Ceph disk are tagged
-  hosts: overcloud 
+  hosts: overcloud
   tags:
     - kolla-ceph
   roles:
-    - role: stackhpc.parted-1-1
     - role: kolla-ceph
       when: kolla_enable_ceph | bool
diff --git a/ansible/roles/kolla-ansible/tasks/install.yml b/ansible/roles/kolla-ansible/tasks/install.yml
index 63b06e46..dbc01bb4 100644
--- a/ansible/roles/kolla-ansible/tasks/install.yml
+++ b/ansible/roles/kolla-ansible/tasks/install.yml
@@ -71,5 +71,6 @@
     dest: "{{ kolla_ansible_venv }}/lib/python2.7/site-packages/selinux"
     state: link
   when:
+    - ansible_os_family == 'RedHat'
     - ansible_selinux != False
     - ansible_selinux.status != 'disabled'
diff --git a/ansible/roles/kolla-ansible/templates/requirements.txt.j2 b/ansible/roles/kolla-ansible/templates/requirements.txt.j2
index 58372842..c7633730 100644
--- a/ansible/roles/kolla-ansible/templates/requirements.txt.j2
+++ b/ansible/roles/kolla-ansible/templates/requirements.txt.j2
@@ -7,4 +7,4 @@ kolla-ansible=={{ kolla_openstack_release }}
 {% endif %}
 # Limit the version of ansible used by kolla-ansible to avoid new releases from
 # breaking tested code. Changes to this limit should be tested.
-ansible<2.4
+ansible<2.6
diff --git a/ansible/roles/kolla-ceph/tasks/config.yml b/ansible/roles/kolla-ceph/tasks/config.yml
index 0a542b30..ee5b29d4 100644
--- a/ansible/roles/kolla-ceph/tasks/config.yml
+++ b/ansible/roles/kolla-ceph/tasks/config.yml
@@ -1,5 +1,4 @@
 ---
-# (ktibi) Need to remove parted_1_1 module when kayobe will support ansible 2.4
 
 - name: Ensure required packages are installed
   package:
@@ -10,18 +9,18 @@
 
 - name: Check the presence of a partition on the OSD disks
   become: True
-  parted_1_1:
+  parted:
     device: "{{ item.osd }}"
   with_items: "{{ ceph_disks }}"
   register: "disk_osd_info"
 
 - name: Check the presence of a partition on the journal disks
   become: True
-  parted_1_1:
+  parted:
     device: "{{ item.journal }}"
   with_items: "{{ ceph_disks }}"
   register: "disk_journal_info"
-  when: 
+  when:
     - item.journal is defined
 
 - name: Fail if the Ceph OSD disks have already a partition
@@ -51,7 +50,7 @@
 
 - name: Create tag partition for Ceph OSD
   become: True
-  parted_1_1:
+  parted:
     device: "{{ item.item.osd }}"
     number: 1
     label: gpt
@@ -68,7 +67,7 @@
 
 - name: Create tag partition for Ceph external journal
   become: True
-  parted_1_1:
+  parted:
     device: "{{ item.item.journal }}"
     number: 1
     label: gpt
diff --git a/ansible/roles/kolla-ceph/tests/test-bootstrapped-journal.yml b/ansible/roles/kolla-ceph/tests/test-bootstrapped-journal.yml
index a32fd177..077dfa53 100644
--- a/ansible/roles/kolla-ceph/tests/test-bootstrapped-journal.yml
+++ b/ansible/roles/kolla-ceph/tests/test-bootstrapped-journal.yml
@@ -22,7 +22,7 @@
 
     - name: Create tag partition for the fake OSD
       become: True
-      parted_1_1:
+      parted:
         device: "{{ osd_tempfile.path }}"
         number: 1
         label: gpt
@@ -34,7 +34,7 @@
 
     - name: Create tag partition for the fake journal
       become: True
-      parted_1_1:
+      parted:
         device: "{{ journal_tempfile.path }}"
         number: 1
         label: gpt
@@ -45,10 +45,6 @@
         osd_id: "{{ osd_tempfile.path | basename }}{{ ansible_hostname }}"
 
     - block:
-        - name: Import parted role
-          include_role:
-            name: ../../stackhpc.parted-1-1
-
         - name: Test the kolla-ceph role
           include_role:
             name:  ../../kolla-ceph
@@ -58,7 +54,7 @@
                    journal: "{{ journal_tempfile.path }}"
 
         - name: Get name of fake OSD partition
-          parted_1_1:
+          parted:
             device: "{{ osd_tempfile.path }}"
           register: "disk_osd_info"
           become: True
@@ -80,7 +76,7 @@
             expected: "{{ 'KOLLA_CEPH_OSD_BOOTSTRAP_' ~ ((osd_tempfile.path | basename ~ ansible_hostname) | hash('md5'))[:9] }}"
 
         - name: Get name of fake journal partition
-          parted_1_1:
+          parted:
             device: "{{ journal_tempfile.path }}"
           register: "disk_journal_info"
           become: True
diff --git a/ansible/roles/kolla-ceph/tests/test-data-journal.yml b/ansible/roles/kolla-ceph/tests/test-data-journal.yml
index 6fdf489b..30b94caf 100644
--- a/ansible/roles/kolla-ceph/tests/test-data-journal.yml
+++ b/ansible/roles/kolla-ceph/tests/test-data-journal.yml
@@ -21,7 +21,7 @@
 
     - name: Create tag partition for the fake OSD
       become: True
-      parted_1_1:
+      parted:
         device: "{{ osd_tempfile.path }}"
         number: 1
         label: gpt
@@ -33,7 +33,7 @@
 
     - name: Create tag partition for the fake journal
       become: True
-      parted_1_1:
+      parted:
         device: "{{ journal_tempfile.path }}"
         number: 1
         label: gpt
@@ -44,10 +44,6 @@
         osd_id: "{{ (osd_tempfile.path | basename ~ ansible_hostname) }}"
 
     - block:
-        - name: Import parted role
-          include_role:
-            name: ../../stackhpc.parted-1-1
-
         - name: Test the kolla-ceph role
           include_role:
             name:  ../../kolla-ceph
@@ -57,7 +53,7 @@
                    journal: "{{ journal_tempfile.path }}"
 
         - name: Get name of fake OSD partition
-          parted_1_1:
+          parted:
             device: "{{ osd_tempfile.path }}"
           register: "disk_osd_info"
           become: True
@@ -79,7 +75,7 @@
             expected: "{{ 'KOLLA_CEPH_DATA_' ~ ((osd_tempfile.path | basename ~ ansible_hostname)| hash('md5'))[:9] }}"
 
         - name: Get name of fake journal partition
-          parted_1_1:
+          parted:
             device: "{{ journal_tempfile.path }}"
           register: "disk_journal_info"
           become: True
diff --git a/ansible/roles/kolla-ceph/tests/test-journal.yml b/ansible/roles/kolla-ceph/tests/test-journal.yml
index 850a805f..8e568210 100644
--- a/ansible/roles/kolla-ceph/tests/test-journal.yml
+++ b/ansible/roles/kolla-ceph/tests/test-journal.yml
@@ -20,10 +20,6 @@
       command: fallocate -l 10M {{ journal_tempfile.path }}
 
     - block:
-        - name: Import parted role
-          include_role:
-            name: ../../stackhpc.parted-1-1
-
         - name: Test the kolla-ceph role
           include_role:
             name:  ../../kolla-ceph
@@ -33,7 +29,7 @@
                    journal: "{{ journal_tempfile.path }}"
 
         - name: Get name of fake OSD partition
-          parted_1_1:
+          parted:
             device: "{{ osd_tempfile.path }}"
           register: "disk_osd_info"
           become: True
@@ -55,7 +51,7 @@
             expected: "{{ 'KOLLA_CEPH_OSD_BOOTSTRAP_' ~ ((osd_tempfile.path | basename ~ ansible_hostname)| hash('md5'))[:9] }}"
 
         - name: Get name of fake journal partition
-          parted_1_1:
+          parted:
             device: "{{ journal_tempfile.path }}"
           register: "disk_journal_info"
           become: True
diff --git a/ansible/roles/kolla-ceph/tests/test-no-journal.yml b/ansible/roles/kolla-ceph/tests/test-no-journal.yml
index 8c0dec3f..ec164f4a 100644
--- a/ansible/roles/kolla-ceph/tests/test-no-journal.yml
+++ b/ansible/roles/kolla-ceph/tests/test-no-journal.yml
@@ -13,10 +13,6 @@
       command: fallocate -l 10M {{ tempfile.path }}
 
     - block:
-        - name: Import parted role
-          include_role:
-            name: ../../stackhpc.parted-1-1
-
         - name: Test the kolla-ceph role
           include_role:
             name:  ../../kolla-ceph
@@ -25,7 +21,7 @@
                  - osd: "{{ tempfile.path }}"
 
         - name: Get name of fake partition
-          parted_1_1:
+          parted:
             device: "{{ tempfile.path }}"
           register: "disk_osd_info"
           become: True
diff --git a/releasenotes/notes/ansible-2.5-785e3c764f450d09.yaml b/releasenotes/notes/ansible-2.5-785e3c764f450d09.yaml
new file mode 100644
index 00000000..ccce47a4
--- /dev/null
+++ b/releasenotes/notes/ansible-2.5-785e3c764f450d09.yaml
@@ -0,0 +1,4 @@
+---
+features:
+  - Adds support for the Ansible 2.5 release.  The version requirement has been
+    increased for both kayobe and kolla ansible.
diff --git a/requirements.txt b/requirements.txt
index 7cab5504..1753d82a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,7 +7,7 @@ pbr>=2.0 # Apache-2.0
 # with the fix backported. It can be installed by uncommenting the following
 # line and commenting the one after.
 # -e git+https://github.com/stackhpc/ansible@issue-30350-2.3#egg=ansible-issue-30350-2.3 # GPLv3
-ansible<2.4.0 # GPLv3
+ansible>=2.4.0,<2.6.0 # GPLv3
 cliff>=2.5.0 # Apache
 netaddr!=0.7.16,>=0.7.13 # BSD
 PyYAML>=3.10.0 # MIT
diff --git a/requirements.yml b/requirements.yml
index c0ae60f7..0cc06d68 100644
--- a/requirements.yml
+++ b/requirements.yml
@@ -8,7 +8,6 @@
 - src: https://github.com/stackhpc/ansible-users
   version: append
   name: singleplatform-eng.users
-- src: stackhpc.parted-1-1
 - src: stackhpc.drac
 - src: stackhpc.drac-facts
 - src: stackhpc.grafana-conf
-- 
GitLab