Skip to content

Commit

Permalink
Merge pull request #175 from wheelerlaw/fix_cleanup
Browse files Browse the repository at this point in the history
Fix small bugs and add pre- and post-hooks to some roles
  • Loading branch information
dirgim authored Jan 6, 2021
2 parents 447a57c + fd2ddf1 commit b85609f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion playbooks/group_vars/all/global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run_cleanup: false
run_prereqs: false
setup_nested_virt: false
setup_minishift: true
start_minishift: false
start_minishift: true
setup_containers: true
setup_helper_containers: true
setup_pipelines: false
Expand Down
2 changes: 1 addition & 1 deletion playbooks/roles/cleanup/tasks/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
path: "{{ item }}"
state: absent
with_items:
- "{{ contra_env_setup_dir }}/{{ project_dir }}"
- "{{ project_dir }}"
when:
- pd_is_found.stat.exists
- force_repo_clone|bool == true
12 changes: 11 additions & 1 deletion playbooks/roles/cleanup/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
---
# tasks file for cleanup

- name: "Running cleanup pre-tasks {{ cleanup_pre_hooks }}"
include_tasks: "{{ item }}"
with_items: "{{ cleanup_pre_hooks }}"
when: cleanup_pre_hooks is defined

- name: "Stop minishift if running"
import_tasks: cleanup.yml
import_tasks: cleanup.yml

- name: "Running cleanup post-tasks {{ cleanup_post_hooks }}"
include_tasks: "{{ item }}"
with_items: "{{ cleanup_post_hooks }}"
when: cleanup_post_hooks is defined
2 changes: 1 addition & 1 deletion playbooks/roles/create/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

# Clone the project_repo and sample_project_repo
- name: "Clone the project repo {{ project_repo }}"
import_tasks: clone_repos.yml
import_tasks: clone_repos.yml
6 changes: 2 additions & 4 deletions playbooks/roles/minishift/tasks/init_minishift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
- name: "Wait for the cluster to come up completely"
pause:
minutes: 3
when: (cpu_mode_not_configured|bool) or
(start_minishift|bool == false)
when: (cpu_mode_not_configured|bool)

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

- name: "Update the minishift VM config"
lineinfile:
Expand Down
13 changes: 11 additions & 2 deletions playbooks/roles/minishift/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
# setup minishift

- name: "Running minishift pre-tasks {{ minishift_pre_hooks }}"
include_tasks: "{{ item }}"
with_items: "{{ minishift_pre_hooks }}"
when: minishift_pre_hooks is defined

- fail:
msg: 'setup_minishift cannot be true with a defined value for openshift_cluster_ip'
when: openshift_cluster_ip != ""
Expand Down Expand Up @@ -74,9 +79,13 @@
when: ((minishift_profile_status.stdout_lines and minishift_profile_status.stdout_lines[0]|lower == "does not exist") or
(minishift_profile_status.rc != 0)) and (minishift_external_vm_ip == "")

# Start minishift on an external VM if configured
# Start minishift on an external VM if configured, then shut it down (if it was configured not to start, but we wanted the profile to exist)
- name: "Initialization of minishift cluster with profile {{ profile }} on an existing VM ip {{ minishift_external_vm_ip }}"
shell: "{{ minishift_bin }} start --profile {{ profile }} --openshift-version {{ oc_version }} --vm-driver generic --remote-ipaddress {{ minishift_external_vm_ip }} --remote-ssh-user {{ minishift_external_vm_user }} --remote-ssh-key {{ minishift_external_vm_ssh_key_location }}"
when: ((minishift_profile_status.stdout_lines and minishift_profile_status.stdout_lines[0]|lower == "does not exist") or
(minishift_profile_status.rc != 0)) and (minishift_external_vm_ip != "")
(minishift_profile_status.rc != 0)) and (minishift_external_vm_ip != "") and (start_minishift|bool == true)

- name: "Running minishift post-tasks {{ minishift_post_hooks }}"
include_tasks: "{{ item }}"
with_items: "{{ minishift_post_hooks }}"
when: minishift_post_hooks is defined

0 comments on commit b85609f

Please sign in to comment.