Skip to content

Commit

Permalink
Merge pull request #44 from arilivigni/master
Browse files Browse the repository at this point in the history
Load helper containers and add start_minishift option
  • Loading branch information
arilivigni authored May 30, 2018
2 parents 93d6838 + 4c836b6 commit 19c9974
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 7 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
- [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)
- [Example 4: Setup on a local machine :: Start Minishift w/profile mysetup + OS templates + Jenkins 2.0 pipelines](#example-4-setup-on-a-local-machine--start-minishift-wprofile-mysetup--os-templates--jenkins-20-pipelines)
- [Example 5: Setup on a local machine :: Using the playbook hooks on contra-env-setup](#example-5-setup-on-a-local-machine--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)
Expand Down Expand Up @@ -184,7 +185,32 @@ _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<br>
Instead of -k you could use --private-key=<absolute_path_to_ssh_private_key>_

### Example 4: Using the playbook hooks on contra-env-setup
### Example 4: Setup on a local machine :: Start Minishift w/profile mysetup + OS templates + Jenkins 2.0 pipelines

1. Install on a local machine as user cloud-user.
2. Setup pre-reqs (kvm driver and nested virtualization)
3. Start minishift cluster with profile mysetup
4. Setup OpenShift s2i templates from the -e project_repo=https://github.com/arilivigni/ci-pipeline
1. Override the project_repo with another one then the default in global.yml
2. OpenShift project -e openshift_project=ari-ci-pipeline
5. Modify my container tags with the tag=develop
6. Setup Jenkins 2.0 pipelines from the project_repo=https://github.com/arilivigni/ci-pipeline
7. Setup sample project templates and pipelines
from the project_repo=https://github.com/CentOS-PaaS-SIG/contra-env-sample-project


```
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 -e start_minishift=true -e profile=mysetup -K -k
```
_Note: The -K is used to prompt you for your password for sudo (if you require one) <br>
The -k is used to prompt you for your ssh password can hit enter if using -K and they are the same<br>
Instead of -k you could use --private-key=<absolute_path_to_ssh_private_key>_

### Example 5: Setup on a local machine :: 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.
Expand Down
8 changes: 8 additions & 0 deletions playbooks/group_vars/all/global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
run_cleanup: false
run_prereqs: true
setup_minishift: true
startup_minishift: false
setup_containers: true
setup_pipelines: false
setup_sample_project: false
Expand Down Expand Up @@ -135,3 +136,10 @@ sample_os_template_dir: "config/s2i"
# Sample Jenkins pipelines directory
sample_pipeline_dir: "config/pipelines/buildconfigs"

## Continuous-Infra helper containers

# Helper project directory
helper_project_dir: "{{ contra_env_setup_dir }}/{{ sample_project_repo.split('/')[-1] | replace('.git', '') }}"

# Helper OpenSift template directory
helper_os_template_dir: "{{ sample_os_template_dir }}"
2 changes: 1 addition & 1 deletion playbooks/roles/create/tasks/clone_repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
refspec: "{{ sample_project_refspec }}"
version: "{{ sample_project_branch }}"
force: yes
when: (project_repo != sample_project_repo and setup_sample_project|bool == true)
when: project_repo != sample_project_repo
2 changes: 1 addition & 1 deletion playbooks/roles/os_temps/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Check if the minishift cluster is started if not then start the cluster
- name: "Startup the minishift cluster"
import_tasks: start_mcluster.yml
when: setup_minishift|bool == true
when: (setup_minishift|bool == true or start_minishift|bool == true)

# Import_tasks install_oc_bin
- name: "Get OpenShift client binary(oc) version {{ oc_version }} to {{ contra_env_setup_dir }}"
Expand Down
14 changes: 13 additions & 1 deletion playbooks/roles/os_temps/tasks/setup_containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
recurse: yes
register: os_templates

- name: "Get helper OpenShift s2i template names from {{ helper_os_template_dir }}/helper"
find:
paths: "{{ helper_project_dir }}/{{ helper_os_template_dir }}/helper"
patterns: '*.yml,*.yaml'
recurse: yes
register: helper_os_templates
when: project_repo != sample_project_repo

- name: "Get sample OpenShift s2i template names from {{ sample_os_template_dir }}/samples"
find:
paths: "{{ sample_project_dir }}/{{ sample_os_template_dir }}/samples"
Expand All @@ -39,7 +47,11 @@
all_templates: "{{ os_templates.files }}"

- set_fact:
all_templates: "{{ os_templates.files }} + {{ sample_os_templates.files }}"
all_templates: "{{ os_templates.files }} + {{ helper_os_templates.files }}"
when: (project_repo != sample_project_repo and setup_sample_project|bool == false)

- set_fact:
all_templates: "{{ os_templates.files }} + {{ sample_os_templates.files }} + {{ helper_os_templates.files }} "
when: (project_repo != sample_project_repo and setup_sample_project|bool == true)

- debug:
Expand Down
2 changes: 1 addition & 1 deletion playbooks/roles/os_temps/tasks/start_mcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

# start minishift profile
- name: "Start minishift profile {{ profile }}"
shell: "{{ minishift_bin }} start --profile {{ profile }} --disk-size {{ disk_size }} --memory {{ memory }} --openshift-version {{ oc_version }} --iso-url file:///{{ minishift_dest_dir }}/minishift.iso"
shell: "{{ minishift_bin }} start --profile {{ profile }} --cpus {{ cpus }} --disk-size {{ disk_size }} --memory {{ memory }} --openshift-version {{ oc_version }} --iso-url file:///{{ minishift_dest_dir }}/minishift.iso"
when: minishift_status.stdout == "Stopped"
2 changes: 1 addition & 1 deletion playbooks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- { role: cleanup, when: run_cleanup|bool == true }
- role: create
- { role: prereqs, when: "run_prereqs|bool == true and setup_minishift|bool == true" }
- { role: minishift, when: setup_minishift|bool == true }
- { role: minishift, when: "setup_minishift|bool == true and start_minishift == false" }
- { role: os_temps, when: setup_containers|bool == true }
- { role: pipeline, when: setup_pipelines|bool == true }
- { role: playbook_hooks, when: setup_playbook_hooks|bool == true }

0 comments on commit 19c9974

Please sign in to comment.