- Contra Environment Setup
- minishift or OpenShift + OpenShift s2i templates + Jenkins pipelines
- Overview
- Getting Started
- Playbooks
- Pre-Setup options
- Override options
- Minishift and OpenShift setup options
- Project repo options that has s2i templates and Jenkins Pipelines
- Templates
- Usage examples
- 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 3: Setup on a local machine :: Setup Minishift + OS templates + Jenkins 2.0 pipelines
- Example 4: Setup on a local machine :: Start Minishift w/profile mysetup + OS templates + Jenkins 2.0 pipelines
- Example 5: Setup on a local machine :: Using the playbook hooks on contra-env-setup
- Debugging Issues
The intent of this setup is to provide a generic way to setup a minishift environment if required or provide an OpenShift endpoint to setup OpenShift s2i templates and Jenkins 2.0 pipelines from some other projects repo. Then the process is automated and a developer or project team can setup their environment with ease.
You need to have some sort of inventory file just as you do for running any ansible inventory. This can be a static file, dynamic inventory, or a comma separated list of machines.
- "10.10.10.1,10.10.10.2,"
- ansible inventory
- ansible dynamic inventory
This will setup the minishift + pipeline development environment. It can setup the entire environment or only certain components. ex. minishift, jenkins infra, pipeline containers, and fed-msg relay
contra-env-setup/playbooks/group_vars/all/global.yml
- run_cleanup: Run clean up of previous setup : default=false
- run_prereqs: Run setting up virtualization and kvm-driver : default=true
- contra_env_setup_dir: Directory to store the contra-env-setup : default "{{ ansible_env.HOME }}/.contra-env-setup
- force_minishift_install: Override an existing install of minishift : default=false
- force_repo_clone: Force cloning of project repo
- setup_minishift: Setup a minishift cluster : default=true
- minishift_version: Minishift version to use : default=v1.12.0
- minishift_dest_dir: Minishift binary and ISO directory : default={{ contra_env_setup_dir }}/minishift
- profile: Minishift profile : default=minishift
- user: account to use for libvirt setup
- disk_size: Disk size to use for minishift : default=40gb
- memory: Recommended memory size to use for the VM : default=8092mb
- cpus: Number of cpus to use for minishift VM: default=2
- minishift_iso: ISO image to use : default=http://artifacts.ci.centos.org/fedora-atomic/minishift/iso/minishift.iso
- minishift_insecure_registry: Additional insecure registries : default="" (not used)
- openshift_project: OpenShift project name : default:contra-sample-project
- openshift_project_display_name: OpenShift project display name : default:Contra Sample Project
- openshift_cluster_ip: Cluster IP of OpenShift console. Set this if not using Minishift : default:
- modify_tags: Modify tags of containers : default=true
- tag: Add a tag besides latest : default=stable
- modify_scc: Create/update the security context constraints : default=true
- oc_version: oc version to use to communicate to the OpenShift cluster : default=V3.6.1
- project_repo: Project repo to import templates and pipelines from : default=https://github.com/CentOS-PaaS-SIG/contra-env-sample-project
- project_refspec: Project refspec : default=+refs/pull/:refs/heads/
- project_branch: Project branch : default=master
- project_dir: Project directory where repo is stored locally : default={{ contra_env_setup_dir }}/{{ project_repo.split('/')[-1] }}
- setup_sample_project: Sample profect to setup
- setup_containers: Setup OpenShift s2i templates : default=true
- os_template_dir: Relative directory in the project repo where OpenShift s2i templates are stored: default=config/s2i
- sample_os_template_dir: Relative directory in the sample project repo where OpenShift s2i templates are stored: default=config/s2i
- setup_pipelines: Setup Jenkins 2.0 pipelines : default=false
- pipeline_dir: Relative directory in the project repo where Jenkins pipelines are stored: default=config/pipelines/buildconfigs
- sample_pipeline_dir: Relative directory in the sample project repo where Jenkins pipelines are stored: default=config/pipelines/buildconfigs
Note that it is possible to use {{ ansible_vars }} in your Openshift Templates.
- Install on a local machine as user cloud-user.
- Setup pre-reqs (kvm driver and nested virtualization)
- Setup a minishift cluster
- Setup OpenShift s2i templates from the -e project_repo=https://github.com/arilivigni/ci-pipeline
- Override the project_repo with another one then the default in global.yml
- OpenShift project -e openshift_project=ari-ci-pipeline
- Modify my container tags with the default tag. tag=stable
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 -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=<absolute_path_to_ssh_private_key>
- Install on a local machine as user cloud-user.
- Setup pre-reqs (kvm driver and nested virtualization)
- Setup a minishift cluster
- Setup OpenShift s2i templates from the -e project_repo=https://github.com/arilivigni/ci-pipeline
- Override the project_repo with another one then the default in global.yml
- OpenShift project -e openshift_project=ari-ci-pipeline
- Modify my container tags with the default tag. tag=stable
- Setup Jenkins 2.0 pipelines from the project_repo=https://github.com/arilivigni/ci-pipeline
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 setup_pipelines=true -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=<absolute_path_to_ssh_private_key>
- Install on a local machine as user cloud-user.
- Setup pre-reqs (kvm driver and nested virtualization)
- Setup a minishift cluster
- Setup OpenShift s2i templates from the -e project_repo=https://github.com/arilivigni/ci-pipeline
- Override the project_repo with another one then the default in global.yml
- OpenShift project -e openshift_project=ari-ci-pipeline
- Modify my container tags with the tag=develop
- Setup Jenkins 2.0 pipelines from the project_repo=https://github.com/arilivigni/ci-pipeline
- 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 -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=<absolute_path_to_ssh_private_key>
Example 4: Setup on a local machine :: Start Minishift w/profile mysetup + OS templates + Jenkins 2.0 pipelines
- Install on a local machine as user cloud-user.
- Setup pre-reqs (kvm driver and nested virtualization)
- Start minishift cluster with profile mysetup
- Setup OpenShift s2i templates from the -e project_repo=https://github.com/arilivigni/ci-pipeline
- Override the project_repo with another one then the default in global.yml
- OpenShift project -e openshift_project=ari-ci-pipeline
- Modify my container tags with the tag=develop
- Setup Jenkins 2.0 pipelines from the project_repo=https://github.com/arilivigni/ci-pipeline
- 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=<absolute_path_to_ssh_private_key>
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"]}'
Example 6: Setup on a local machine :: Start Minishift w/profile mysetup + OS templates + Jenkins 2.0 pipelines
- Install on a local machine as user cloud-user.
- Setup pre-reqs (kvm driver and nested virtualization)
- Start minishift cluster with profile mysetup
- Setup OpenShift s2i templates from the -e project_repo=https://github.com/arilivigni/ci-pipeline
- Override the project_repo with another one then the default in global.yml
- OpenShift project -e openshift_project=ari-ci-pipeline
- Disable setup of the helper containers ansible-executor and linchpin-executor
- Setup Jenkins 2.0 pipelines from the project_repo=https://github.com/arilivigni/ci-pipeline
- 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 setup_helper_containers=false -e setup_pipelines=true \
-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=<absolute_path_to_ssh_private_key>
This issue reveals itself as not being able to pull images from the docker registry. This is because your minishift VM can't reach outside addresses.
Pinpointing if you are hitting this issue:
- In the output of the following task:
TASK [minishift : Initialization of minishift cluster with profile minishiftpipeline]
- Task contains:
Pinging 8.8.8.8 ... FAIL
- Full example output: http://pastebin.centos.org/620286/
Make sure you can ping outside addresses from within the minishift vm.
- Test pinging an outside address from the minishift VM
minishift ssh
ping www.google.com
If the above fails try switching network connection being used from wireless to wired or checking the firewall on that network if it is blocking the traffic