From 73c821fc338268c2ae7db1ada5b5c71b8a2683f3 Mon Sep 17 00:00:00 2001 From: Marcelo Barbosa Date: Wed, 16 May 2018 13:18:46 +0200 Subject: [PATCH] add the ability to specify adhoc oc commands --- README.md | 22 ++++++++++++++++--- playbooks/group_vars/all/global.yml | 1 + playbooks/roles/playbook_hooks/tasks/main.yml | 6 +++++ playbooks/setup.yml | 3 ++- test/README.md | 13 +++++++++++ 5 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 playbooks/roles/playbook_hooks/tasks/main.yml diff --git a/README.md b/README.md index e2ef0379..9cdd7aa5 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,12 @@ - [Project repo options that has s2i templates and Jenkins Pipelines](#project-repo-options-that-has-s2i-templates-and-jenkins-pipelines) - [OpenShift s2i template setup options](#openshift-s2i-template-setup-options) - [Jenkins 2.0 pipeline setup options](#jenkins-20-pipeline-setup-options) + - [Templates](#templates) - [Usage examples](#usage-examples) - - [Example 1: Setup on a local server :: Setup Minishift + OS templates](#example-1-setup-on-a-local-server--setup-minishift--os-templates) - - [Example 2: Setup on a local server :: Setup Minishift + OS templates + Jenkins 2.0 pipelines](#example-2-setup-on-a-local-server--setup-minishift--os-templates--jenkins-20-pipelines) - - [Example 3: Setup on a local server :: Setup Minishift + OS templates + Jenkins 2.0 pipelines](#example-3-setup-on-a-local-server--setup-minishift--os-templates--jenkins-20-pipelines) + - [Example 1: Setup on a local machine :: Setup Minishift + OS templates](#example-1-setup-on-a-local-machine--setup-minishift--os-templates) + - [Example 2: Setup on a local machine :: Setup Minishift + OS templates + Jenkins 2.0 pipelines](#example-2-setup-on-a-local-machine--setup-minishift--os-templates--jenkins-20-pipelines) + - [Example 3: Setup on a local machine :: Setup Minishift + OS templates + Jenkins 2.0 pipelines](#example-3-setup-on-a-local-machine--setup-minishift--os-templates--jenkins-20-pipelines) + - [Example 4: Using the playbook hooks on contra-env-setup](#example-4-using-the-playbook-hooks-on-contra-env-setup) - [Debugging Issues](#debugging-issues) - [Issue #1: Can't push images to the Minishift cluster](#issue-1-cant-push-images-to-the-minishift-cluster) - [Solution #1:](#solution-1) @@ -182,6 +184,20 @@ _Note: The -K is used to prompt you for your password for sudo (if you require o The -k is used to prompt you for your ssh password can hit enter if using -K and they are the same
Instead of -k you could use --private-key=_ +### Example 4: Using the playbook hooks on contra-env-setup + +This resource permit to create your playbooks to included as the last role that will be +executed on contra-env-setup. + +``` + ansible-playbook -vv -i "localhost," contra-env-setup/playbooks/setup.yml \ + -e user=cloud-user -e project_repo=https://github.com/arilivigni/ci-pipeline \ + -e openshift_project=ari-ci-pipeline -e tag=develop -e setup_pipelines=true \ + -e setup_sample_project -K -k + --extra-vars='{"hooks": ["/contra-env-setup/playbook_a.yml","/contra-env-setup/playbook_b.yml"]}' + +``` + ## Debugging Issues ### Issue #1: Can't push images to the Minishift cluster diff --git a/playbooks/group_vars/all/global.yml b/playbooks/group_vars/all/global.yml index 82a5384a..9451cf6e 100644 --- a/playbooks/group_vars/all/global.yml +++ b/playbooks/group_vars/all/global.yml @@ -6,6 +6,7 @@ setup_minishift: true setup_containers: true setup_pipelines: false setup_sample_project: false +setup_playbook_hooks: false force_minishift_install: false force_repo_clone: true diff --git a/playbooks/roles/playbook_hooks/tasks/main.yml b/playbooks/roles/playbook_hooks/tasks/main.yml new file mode 100644 index 00000000..618ec96d --- /dev/null +++ b/playbooks/roles/playbook_hooks/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- debug: msg="{{ hooks }}" + +- name: "Adding external playbooks" + include: "{{ item }}" + with_items: "{{ hooks }}" \ No newline at end of file diff --git a/playbooks/setup.yml b/playbooks/setup.yml index 2ef2418e..f763890f 100644 --- a/playbooks/setup.yml +++ b/playbooks/setup.yml @@ -10,4 +10,5 @@ - { role: prereqs, when: "run_prereqs|bool == true and setup_minishift|bool == true" } - { role: minishift, when: setup_minishift|bool == true } - { role: os_temps, when: setup_containers|bool == true } - - { role: pipeline, when: setup_pipelines|bool == true } \ No newline at end of file + - { role: pipeline, when: setup_pipelines|bool == true } + - { role: playbook_hooks, when: setup_playbook_hooks|bool == true } diff --git a/test/README.md b/test/README.md index 12f2bc9c..d4c8d714 100644 --- a/test/README.md +++ b/test/README.md @@ -1,3 +1,16 @@ + + +**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* + +- [contra-env-setup CI](#contra-env-setup-ci) + - [Avocado](#avocado) + - [How to install](#how-to-install) + - [Tests](#tests) + - [Running the test](#running-the-test) + - [References](#references) + + + # contra-env-setup CI This document describes how works the tests in the contra-env-setup repository.