summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Peck <bill@pecknet.com>2019-11-27 08:35:45 -0500
committerBill Peck <bill@pecknet.com>2019-12-03 11:09:47 -0500
commitc3a91c2911b49fb0a84b29abd6ebde4f3687a678 (patch)
tree620f720efd8243bc26b5ee3fc530c0132bb983e7
parentfd351347c30b91cc789f212a7bd10e08aa96e14d (diff)
Initial code for cki ansible role
Change-Id: I488287379a95dea976b19aee9ce94f1607ed1123
-rw-r--r--LICENSE175
-rw-r--r--README.md0
-rw-r--r--ansible-role-dci-rhel-cki.spec39
-rw-r--r--files/job2dciplaybook.xsl144
-rw-r--r--files/job2restraint.xsl116
-rw-r--r--meta/main.yml16
-rw-r--r--molecule/default/Dockerfile.j212
-rw-r--r--molecule/default/molecule.yml35
-rw-r--r--molecule/default/playbook.yml7
-rw-r--r--tasks/main.yml31
-rw-r--r--tox.ini19
11 files changed, 594 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..19dc35b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,175 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability. \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README.md
diff --git a/ansible-role-dci-rhel-cki.spec b/ansible-role-dci-rhel-cki.spec
new file mode 100644
index 0000000..5b52fe0
--- /dev/null
+++ b/ansible-role-dci-rhel-cki.spec
@@ -0,0 +1,39 @@
+%define _source_payload w0.gzdio
+%define _binary_payload w0.gzdio
+
+Name: ansible-role-dci-rhel-cki
+Version: 0.0.1
+Release: 1%{?dist}
+Summary: ansible-role-dci-rhel-cki
+License: ASL 2.0
+URL: https://github.com/redhat-cip/ansible-role-dci-rhel-cki
+Source0: ansible-role-dci-rhel-cki-%{version}.tar.gz
+
+BuildArch: noarch
+
+%description
+An Ansible role that is used to automate cki testing
+
+%prep
+%setup -qc
+
+
+%build
+
+%install
+mkdir -p %{buildroot}%{_datadir}/dci/roles/dci-rhel-cki
+chmod 755 %{buildroot}%{_datadir}/dci/roles/dci-rhel-cki
+
+cp -r files %{buildroot}%{_datadir}/dci/roles/dci-rhel-cki
+cp -r tasks %{buildroot}%{_datadir}/dci/roles/dci-rhel-cki
+
+
+%files
+%doc README.md
+%license LICENSE
+%{_datadir}/dci/roles/dci-rhel-cki
+
+
+%changelog
+* Wed Nov 27 2019 Bill Peck <bpeck@redhat.com> - 0.0.1-1
+- Initial release
diff --git a/files/job2dciplaybook.xsl b/files/job2dciplaybook.xsl
new file mode 100644
index 0000000..f3084a4
--- /dev/null
+++ b/files/job2dciplaybook.xsl
@@ -0,0 +1,144 @@
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output omit-xml-declaration="yes" indent="yes"/>
+ <xsl:output method="text" media-type="text/yml"/>
+ <!-- <xsl:strip-space elements="*"/> -->
+ <xsl:template match="text()"/>
+ <xsl:template match="job/recipeSet/recipe[1]">---
+<xsl:apply-templates/>
+</xsl:template>
+<xsl:template match="task[fetch]">
+ <xsl:variable name="repo_branch">
+ <xsl:call-template name="getRepoBranch">
+ <xsl:with-param name="value" select="fetch/@url"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="repo_uri">
+ <xsl:call-template name="getRepoURI">
+ <xsl:with-param name="value" select="fetch/@url"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="schema">
+ <xsl:call-template name="getRepoSchema">
+ <xsl:with-param name="value" select="fetch/@url"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="repo_base_path">
+ <xsl:call-template name="getRepoBasePath">
+ <xsl:with-param name="value" select="$repo_uri"/>
+ <xsl:with-param name="schema" select="$schema"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="dirname">
+ <xsl:call-template name="getDirname">
+ <xsl:with-param name="value" select="$repo_base_path"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="basename">
+ <xsl:call-template name="getBasename">
+ <xsl:with-param name="value" select="$repo_base_path"/>
+ </xsl:call-template>
+ </xsl:variable>- name: Create task directory if it does not exist
+ delegate_to: localhost
+ file:
+ path: /var/www/html/tasks/<xsl:value-of select="$dirname"/>
+ state: directory
+ mode: '0755'
+<xsl:choose>
+ <xsl:when test="$schema = 'git://'">- name: Get Task <xsl:value-of select="fetch/@url"/>
+ delegate_to: localhost
+ git:
+ repo: <xsl:value-of select="$repo_uri"/>
+ dest: ./git_repos/<xsl:value-of select="$repo_base_path"/>
+ version: <xsl:value-of select="$repo_branch"/>
+ depth: 1
+ run_once: True
+- name: Archive Task
+ delegate_to: localhost
+ archive:
+ path: ./git_repos/<xsl:value-of select="$repo_base_path"/>/
+ dest: /var/www/html/tasks/<xsl:value-of select="$dirname"/><xsl:value-of select="$basename"/>.tgz
+
+</xsl:when>
+ <xsl:otherwise>- name: Download Task
+ delegate_to: localhost
+ get_url:
+ url: <xsl:value-of select="$repo_uri"/>
+ dest: /var/www/html/tasks/<xsl:value-of select="$dirname"/><xsl:value-of select="$basename"/>
+ mode: 0755
+
+</xsl:otherwise>
+ </xsl:choose>
+
+</xsl:template>
+ <xsl:template name="getRepoBranch">
+ <xsl:param name="value"/>
+ <xsl:choose>
+ <xsl:when test="string-length($value) != string-length(translate($value,'?',''))">
+ <xsl:variable name="branch_path" select="substring-after($value, '?')"/>
+ <xsl:choose>
+ <xsl:when test="string-length($branch_path) != string-length(translate($branch_path, '#', ''))">
+ <xsl:value-of select="substring-before($branch_path, '#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$branch_path"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="'HEAD'"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template name="getRepoURI">
+ <xsl:param name="value"/>
+ <xsl:choose>
+ <xsl:when test="string-length($value) != string-length(translate($value, '?', ''))">
+ <xsl:value-of select="substring-before($value, '?')"/>
+ </xsl:when>
+ <xsl:when test="string-length($value) != string-length(translate($value, '#', ''))">
+ <xsl:value-of select="substring-before($value, '#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template name="getRepoSchema">
+ <xsl:param name="value"/>
+ <xsl:value-of select="substring-before($value, '://')"/><xsl:value-of select="'://'"/>
+ </xsl:template>
+ <xsl:template name="getRepoBasePath">
+ <xsl:param name="value"/>
+ <xsl:param name="schema"/>
+ <xsl:value-of select="substring-after($value, $schema)"/>
+ </xsl:template>
+ <xsl:template name="getDirname">
+ <xsl:param name="value" />
+ <xsl:param name="separator" select="'/'" />
+ <xsl:choose>
+ <xsl:when test="contains($value, $separator)">
+ <xsl:value-of select="substring-before($value, $separator)"/><xsl:value-of select="'/'"/>
+ <xsl:call-template name="getDirname">
+ <xsl:with-param name="value" select="substring-after($value, $separator)" />
+ <xsl:with-param name="separator" select="$separator" />
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template name="getBasename">
+ <xsl:param name="value" />
+ <xsl:param name="separator" select="'/'" />
+ <xsl:choose>
+ <xsl:when test="contains($value, $separator)">
+ <xsl:call-template name="getBasename">
+ <xsl:with-param name="value" select="substring-after($value, $separator)" />
+ <xsl:with-param name="separator" select="$separator" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/files/job2restraint.xsl b/files/job2restraint.xsl
new file mode 100644
index 0000000..eb759d2
--- /dev/null
+++ b/files/job2restraint.xsl
@@ -0,0 +1,116 @@
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <!-- <xsl:output omit-xml-declaration="yes" indent="yes"/>-->
+ <xsl:output method="xml" indent="yes"/>
+ <!-- <xsl:strip-space elements="*"/> -->
+ <xsl:template match="text()"/>
+ <xsl:template match="job/recipeSet/recipe[1]"><job><recipeSet><recipe>
+<xsl:apply-templates/></recipe></recipeSet></job>
+</xsl:template>
+<xsl:template match="task[fetch]">
+ <xsl:variable name="repo_sub_path">
+ <xsl:call-template name="getRepoSubPath">
+ <xsl:with-param name="value" select="fetch/@url"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="repo_uri">
+ <xsl:call-template name="getRepoURI">
+ <xsl:with-param name="value" select="fetch/@url"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="schema">
+ <xsl:call-template name="getRepoSchema">
+ <xsl:with-param name="value" select="fetch/@url"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="repo_base_path">
+ <xsl:call-template name="getRepoBasePath">
+ <xsl:with-param name="value" select="$repo_uri"/>
+ <xsl:with-param name="schema" select="$schema"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="dirname">
+ <xsl:call-template name="getDirname">
+ <xsl:with-param name="value" select="$repo_base_path"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="basename">
+ <xsl:call-template name="getBasename">
+ <xsl:with-param name="value" select="$repo_base_path"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <task>
+ <xsl:attribute name="name">
+ <xsl:value-of select="@name"/>
+ </xsl:attribute>
+ <xsl:copy-of select="params" />
+ <fetch>
+ <xsl:attribute name="url">http://<xsl:value-of select="$jumpHost"/>/tasks/<xsl:value-of select="$dirname"/><xsl:value-of select="$basename"/><xsl:choose><xsl:when test="$schema = 'git://'"><xsl:value-of select="'.tgz'"/></xsl:when></xsl:choose>#<xsl:value-of select="$repo_sub_path"/>
+ </xsl:attribute>
+ </fetch>
+ </task>
+</xsl:template>
+
+ <xsl:template name="getRepoSubPath">
+ <xsl:param name="value"/>
+ <xsl:choose>
+ <xsl:when test="not(string-length(translate($value, '#', ''))=string-length())">
+ <xsl:value-of select="substring-after($value, '#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="''"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template name="getRepoURI">
+ <xsl:param name="value"/>
+ <xsl:choose>
+ <xsl:when test="string-length($value) != string-length(translate($value, '?', ''))">
+ <xsl:value-of select="substring-before($value, '?')"/>
+ </xsl:when>
+ <xsl:when test="string-length($value) != string-length(translate($value, '#', ''))">
+ <xsl:value-of select="substring-before($value, '#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template name="getRepoSchema">
+ <xsl:param name="value"/>
+ <xsl:value-of select="substring-before($value, '://')"/><xsl:value-of select="'://'"/>
+ </xsl:template>
+ <xsl:template name="getRepoBasePath">
+ <xsl:param name="value"/>
+ <xsl:param name="schema"/>
+ <xsl:value-of select="substring-after($value, $schema)"/>
+ </xsl:template>
+ <xsl:template name="getDirname">
+ <xsl:param name="value" />
+ <xsl:param name="separator" select="'/'" />
+ <xsl:choose>
+ <xsl:when test="contains($value, $separator)">
+ <xsl:value-of select="substring-before($value, $separator)"/><xsl:value-of select="'/'"/>
+ <xsl:call-template name="getDirname">
+ <xsl:with-param name="value" select="substring-after($value, $separator)" />
+ <xsl:with-param name="separator" select="$separator" />
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template name="getBasename">
+ <xsl:param name="value" />
+ <xsl:param name="separator" select="'/'" />
+ <xsl:choose>
+ <xsl:when test="contains($value, $separator)">
+ <xsl:call-template name="getBasename">
+ <xsl:with-param name="value" select="substring-after($value, $separator)" />
+ <xsl:with-param name="separator" select="$separator" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/meta/main.yml b/meta/main.yml
new file mode 100644
index 0000000..220ed9e
--- /dev/null
+++ b/meta/main.yml
@@ -0,0 +1,16 @@
+---
+galaxy_info:
+ author: Distributed-CI Team
+ description: An Ansible role to run the Red Hat RHEL cki test suite
+ company: Red Hat
+ license: license (Apache)
+ min_ansible_version: 2.0
+ platforms:
+ - name: EL
+ versions:
+ - 7
+ - 8
+
+ galaxy_tags: []
+
+dependencies: []
diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2
new file mode 100644
index 0000000..0529528
--- /dev/null
+++ b/molecule/default/Dockerfile.j2
@@ -0,0 +1,12 @@
+{% if item.registry is defined %}
+FROM {{ item.registry.url }}/{{ item.image }}
+{% else %}
+FROM {{ item.image }}
+{% endif %}
+
+RUN yum install -y sudo && \
+ yum clean all
+
+RUN adduser centos && \
+ echo 'centos ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/90-centos && \
+ chmod 440 /etc/sudoers.d/90-centos
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
new file mode 100644
index 0000000..0d217ee
--- /dev/null
+++ b/molecule/default/molecule.yml
@@ -0,0 +1,35 @@
+---
+dependency:
+ name: galaxy
+ enabled: false
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: el7
+ image: centos:latest
+ command: /sbin/init
+ capabilities:
+ - SYS_ADMIN
+provisioner:
+ log: true
+ name: ansible
+ connection_options:
+ ansible_user: centos
+ lint:
+ name: ansible-lint
+scenario:
+ name: default
+ test_sequence:
+ - lint
+ - destroy
+ - dependency
+ - syntax
+ - create
+ - prepare
+ - destroy
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml
new file mode 100644
index 0000000..d7b31ac
--- /dev/null
+++ b/molecule/default/playbook.yml
@@ -0,0 +1,7 @@
+---
+- name: Converge
+ hosts: all
+ tasks:
+ - import_role:
+ name: ansible-role-dci-rhel-cki
+ become: true
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..94ddf4f
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,31 @@
+---
+# Because restraint needs a key (Ansible uses a password)
+- name: Generate /root/.ssh/id_rsa
+ delegate_to: localhost
+ command: ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -C "" -N ""
+ args:
+ creates: /root/.ssh/id_rsa
+- name: Copy /root/.ssh/id_rsa to SUT # noqa 301
+ delegate_to: localhost
+ command: |
+ /usr/bin/sshpass -p beaker ssh-copy-id -o StrictHostKeyChecking=no \
+ -o UserKnownHostsFile=/dev/null root@{{ fqdn }}
+- name: Process CKI jobs # noqa 301
+ delegate_to: localhost
+ shell: |
+ xsltproc --stringparam jumpHost {{ local_repo_ip }} \
+ files/job2restraint.xsl cki_job.xml > processed_cki_job.xml
+
+- name: Generate CKI playbook # noqa 301
+ delegate_to: localhost
+ shell: |
+ xsltproc --stringparam sutHost {{ fqdn }} files/job2dciplaybook.xsl \
+ /etc/dci-rhel-agent/hooks/cki_job.xml > cki_playbook.yml
+
+- include_tasks: cki_playbook.yml
+
+# Run the test
+- name: Execute restraint processed_cki_job.xml # noqa 301
+ delegate_to: localhost
+ command: |
+ restraint --job processed_cki_job.xml --host 1=root@{{ fqdn }} -v
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..c02fb74
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,19 @@
+[tox]
+minversion = 1.8
+envlist = py{27,36}
+skipsdist = true
+
+[testenv]
+passenv = *
+deps =
+ ansible>=2.7,<2.8
+ docker
+ molecule
+
+[testenv:py27]
+commands =
+ molecule test
+
+[testenv:py36]
+commands =
+ molecule test