From 0efea94054e1f25339b60376bd7ebdd4b767c4b2 Mon Sep 17 00:00:00 2001
From: Andreas Jaeger <aj@suse.com>
Date: Wed, 26 Jun 2019 13:56:36 +0200
Subject: [PATCH] Prepare: Use PDK to build puppet module

The puppet module command is deprecated and
is replaced by using the PDK [1] [2].

The difference between the two commands is only
the output in the pkg directory.

The old puppet module command will create a folder and a tarball with the module.

$ls pkg/
openstack-openstacklib-14.1.0/
openstack-openstacklib-14.1.0.tar.gz

While the PDK will only create the tarball in the
pkg folder. This should be no problem since I can't
find anywhere were we are using the generated folder
in the pkg folder.

This is part 1 in a series of two changes, it contains a role to install
the package dependencies (run in pre.yaml before revoke-sudo is called),
the followup change adds the role to actually build. We need those two
steps to not introduce breakage since the users of build-puppet-module
need to be updated before we can change build-puppet-module.

Change-Id: Ief299751c001542b10fcdf44f1b40a169135877a
Needed-By: https://review.opendev.org/667589
Needed-By: https://review.opendev.org/667595
Co-Authored-By: Tobias Urdin <tobias.urdin@binero.se>
---
 doc/source/puppet-roles.rst                   |  1 +
 roles/install-pdk-dependencies/README.rst     |  5 +++++
 .../install-pdk-dependencies/tasks/main.yaml  | 19 +++++++++++++++++++
 3 files changed, 25 insertions(+)
 create mode 100644 roles/install-pdk-dependencies/README.rst
 create mode 100644 roles/install-pdk-dependencies/tasks/main.yaml

diff --git a/doc/source/puppet-roles.rst b/doc/source/puppet-roles.rst
index 7ac9e64e0..3d0da8b6d 100644
--- a/doc/source/puppet-roles.rst
+++ b/doc/source/puppet-roles.rst
@@ -2,5 +2,6 @@ Puppet Roles
 ============
 
 .. zuul:autorole:: build-puppet-module
+.. zuul:autorole:: install-pdk-dependencies
 .. zuul:autorole:: fetch-puppet-module-output
 .. zuul:autorole:: upload-forge
diff --git a/roles/install-pdk-dependencies/README.rst b/roles/install-pdk-dependencies/README.rst
new file mode 100644
index 000000000..4893ee70f
--- /dev/null
+++ b/roles/install-pdk-dependencies/README.rst
@@ -0,0 +1,5 @@
+Ensure dependencies for Puppet Development Kit are installed
+
+This role installs all dependencies for Puppet Development Kit (PDK)
+so that puppet modules can be build with the PDK and published to the
+forge.
diff --git a/roles/install-pdk-dependencies/tasks/main.yaml b/roles/install-pdk-dependencies/tasks/main.yaml
new file mode 100644
index 000000000..032cd2e32
--- /dev/null
+++ b/roles/install-pdk-dependencies/tasks/main.yaml
@@ -0,0 +1,19 @@
+- name: Install ruby dependencies on Red Hat/SUSE based distribution
+  package:
+    name:
+      - ruby-devel
+      - gcc-c++
+      - make
+    state: present
+  become: yes
+  when: ansible_os_family == "RedHat" or ansible_os_family == "Suse"
+
+- name: Install ruby dependencies on Debian based distribution
+  package:
+    name:
+      - ruby-dev
+      - g++
+      - make
+    state: present
+  become: yes
+  when: ansible_os_family == "Debian"