diff --git a/README.md b/README.md index 9cdd7aa5..53687c23 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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
Instead of -k you could use --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)
+ 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 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. diff --git a/playbooks/group_vars/all/global.yml b/playbooks/group_vars/all/global.yml index 9451cf6e..44ebcfe4 100644 --- a/playbooks/group_vars/all/global.yml +++ b/playbooks/group_vars/all/global.yml @@ -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 @@ -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 }}" diff --git a/playbooks/roles/create/tasks/clone_repos.yml b/playbooks/roles/create/tasks/clone_repos.yml index bce8f44c..7a2655ef 100644 --- a/playbooks/roles/create/tasks/clone_repos.yml +++ b/playbooks/roles/create/tasks/clone_repos.yml @@ -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) \ No newline at end of file + when: project_repo != sample_project_repo \ No newline at end of file diff --git a/playbooks/roles/os_temps/tasks/main.yml b/playbooks/roles/os_temps/tasks/main.yml index 9a3eb76c..f12444a8 100644 --- a/playbooks/roles/os_temps/tasks/main.yml +++ b/playbooks/roles/os_temps/tasks/main.yml @@ -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 }}" diff --git a/playbooks/roles/os_temps/tasks/setup_containers.yml b/playbooks/roles/os_temps/tasks/setup_containers.yml index bf54a4a1..1a7c231f 100644 --- a/playbooks/roles/os_temps/tasks/setup_containers.yml +++ b/playbooks/roles/os_temps/tasks/setup_containers.yml @@ -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" @@ -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: diff --git a/playbooks/roles/os_temps/tasks/start_mcluster.yml b/playbooks/roles/os_temps/tasks/start_mcluster.yml index 17309370..c7aa9abd 100644 --- a/playbooks/roles/os_temps/tasks/start_mcluster.yml +++ b/playbooks/roles/os_temps/tasks/start_mcluster.yml @@ -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" diff --git a/playbooks/setup.yml b/playbooks/setup.yml index f763890f..6356b69e 100644 --- a/playbooks/setup.yml +++ b/playbooks/setup.yml @@ -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 }