Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No need to restart the VM if the config was not updated #82

Merged
merged 1 commit into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions playbooks/roles/minishift/tasks/init_minishift.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
---
# start minishift
- name: "Initialization of minishift cluster with 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"

- name: Wait for the cluster to come up completely
pause:
minutes: 3
- block:
- name: "Check if <cpu mode=host-passthrough/> is already set"
find:
paths: "/etc/libvirt/qemu"
patterns: "{{ profile }}.xml"
contains: '\s*<cpu.*\smode=[\"\'']host-passthrough[\"\''].*/>'
register: minishift_vm_config_files
become: yes

- name: Stop the cluster
shell: "{{ minishift_bin }} stop --profile {{ profile }}"
- set_fact:
cpu_mode_not_configured: ((minishift_vm_config_files | default([])) | length == 0)

- name: "Wait for the cluster to come up completely"
pause:
minutes: 3
when: (cpu_mode_not_configured|bool) or (start_minishift|bool == false)

- name: "Stop the minishift profile {{ profile }}"
shell: "{{ minishift_bin }} stop --profile {{ profile }}"
when: (cpu_mode_not_configured|bool) or (start_minishift|bool == false)

- name: "Update the minishift VM config"
lineinfile:
path: "/etc/libvirt/qemu/{{ profile }}.xml"
insertafter: '\s+</features>'
line: " <cpu mode='host-passthrough'/>"
become: yes
when: cpu_mode_not_configured|bool

- name: "Start minishift profile {{ profile }} again if configured"
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: (cpu_mode_not_configured|bool) and (start_minishift|bool == true)

- name: Update the VM config
lineinfile:
path: "/etc/libvirt/qemu/{{ profile }}.xml"
insertafter: '\s+</features>'
line: " <cpu mode='host-passthrough'/>"
become: yes
when: host_os == "linux"
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 and start_minishift == false" }
- { role: minishift, when: "setup_minishift|bool == true" }
- { role: os_temps, when: setup_containers|bool == true }
- { role: pipeline, when: setup_pipelines|bool == true }
- { role: playbook_hooks, when: setup_playbook_hooks|bool == true }