Skip to content

Commit

Permalink
Merge pull request #148 from dirgim/prepare-vm-for-minishift
Browse files Browse the repository at this point in the history
Add a playbook that prepares external VMs for usage with minishift
  • Loading branch information
dirgim authored Feb 25, 2019
2 parents 16c3317 + 9a96e47 commit 7959451
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,39 @@ _Note: The -K is used to prompt you for your password for sudo (if you require o
Instead of -k you could use --private-key=<absolute_path_to_ssh_private_key>_


### Example 10: Setup on an existing generic virtual machine :: Setup Jenkins with metrics enabled

1. Prepare an existing generic centos7/fedora27+ VM with VM_IP as a USER with paswordless sudo privileges
2. Install on an existing VM as a USER, enable nested virtualization
3. Start minishift cluster with profile minishift
4. Run Jenkins with metrics enabled
5. Load containers from a user defined as project_repo from joejstuart/contra-demo
6. Load helper containers from CentOS-PaaS-SIG/contra-env-infra
7. Setup Jenkins with a a job DSL seed job and sample jobs from CentOS-PaaS-SIG/contra-env-sample-project
8. Disable the linchpin-executor container

```
ansible-playbook -vv -i "VM_IP," -u USER contra-env-setup/playbooks/prepare_vm_for_minishift.yml \
-e setup_nested_virt=true --private-key=PATH_TO_PRIVATE_KEY
ansible-playbook -vv -i "localhost," contra-env-setup/playbooks/setup.yml \
-e user=$USER \
-e profile=minishift \
-e minishift_external_vm_user=USER \
-e minishift_external_vm_ssh_key_location=PATH_TO_PRIVATE_KEY \
-e minishift_external_vm_ip=VM_IP \
-e run_prereqs=false \
-e setup_minishift=true \
-e start_minishift=true \
-e setup_containers=true \
-e helper_project_repo=https://github.com/CentOS-PaaS-SIG/contra-env-infra \
-e helper_project_branch=master \
--extra-vars='{"os_template_blacklist": ["linchpin-executor", "ansible-executor"]}' \
-e project_repo=https://github.com/joejstuart/contra-demo \
-e project_branch=master \
-e jenkins_enable_metrics=true \
-e jenkins_dsl_job_repo=CentOS-PaaS-SIG/contra-env-sample-project -K -k
```

## Mac Users

Expand Down
58 changes: 58 additions & 0 deletions playbooks/prepare_vm_for_minishift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
- hosts: '{{ hosts | default("all") }}'
become: '{{ become | default("yes") }}'
gather_facts: '{{ gather_facts | default("no") }}'

vars:
setup_nested_virt: false

tasks:
- name: "Install python if not installed"
raw: test -e /usr/bin/python || sudo yum install -y python

- name: "Install docker, net-tools and firewalld"
package:
name: "{{ item }}"
state: present
with_items:
- docker
- net-tools
- firewalld

- name: "Ensure group docker exists"
group:
name: docker
state: present

- name: "Adding existing user {{ ansible_user }} to group docker"
user:
name: "{{ ansible_user }}"
groups: docker
append: yes

- name: "Ensure that docker service is running"
service:
name: docker
state: reloaded
enabled: yes

- name: "Set run_prereqs to true for the virtualization setup"
set_fact:
run_prereqs: true
when: setup_nested_virt|bool == true

- name: "Setup nested virtualization on the VM"
import_tasks: "{{ playbook_dir }}/roles/prereqs/tasks/setup_nested_virt.yml"
when: setup_nested_virt|bool == true

- name: "Restart VM if nested virtualization was setup"
shell: sleep 2 && shutdown -r now "Restarting to finish nested virtualization setup"
async: 1
poll: 0
ignore_errors: true
when: setup_nested_virt|bool == true

- name: "Wait for the VM to finish reboot"
wait_for_connection:
timeout: 240
delay: 20
when: setup_nested_virt|bool == true

0 comments on commit 7959451

Please sign in to comment.