summaryrefslogtreecommitdiffstats
path: root/deployment/playbooks/clean.yaml
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2019-02-07 02:08:23 +0530
committerValerii Ponomarov <vponomar@redhat.com>2019-02-07 02:36:02 +0530
commit25fcd9c5aa4c360eff19ef08fc4e2bdff6147ffd (patch)
tree544cf09479861ee7c434a7f9ece19167c14ddf35 /deployment/playbooks/clean.yaml
parenta6c7dead0d6ddad4dae93a4292891617b50b44a0 (diff)
Add end-to-end OCP 'deployment' functionality
Add end-to-end deployment tool of OpenShift and OpenShift Container Storage on top of VMWare. Added code is modified version of the 'reference-architecture/vmware-ansible' dir from the following repo: https://github.com/vponomaryov/openshift-ansible-contrib Read 'deployment/README.rst' file for more details about the deployment tool. Change-Id: Ic96f252ff786cc1ecf24d27f0ec47e324131e41b
Diffstat (limited to 'deployment/playbooks/clean.yaml')
-rw-r--r--deployment/playbooks/clean.yaml66
1 files changed, 66 insertions, 0 deletions
diff --git a/deployment/playbooks/clean.yaml b/deployment/playbooks/clean.yaml
new file mode 100644
index 00000000..68da95ec
--- /dev/null
+++ b/deployment/playbooks/clean.yaml
@@ -0,0 +1,66 @@
+---
+- hosts: localhost
+ ignore_errors: yes
+ vars_files:
+ - vars/main.yaml
+ roles:
+ - instance-groups
+
+- hosts: allnodes
+ ignore_errors: yes
+ vars_files:
+ - vars/main.yaml
+ roles:
+ - rhsm-unregister
+
+- hosts: localhost
+ user: root
+ become: false
+ ignore_errors: yes
+ vars_files:
+ - vars/main.yaml
+ tasks:
+ - name: Delete all added VMs
+ vmware_guest:
+ hostname: "{{ vcenter_host }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: False
+ name: "{{ hostvars[item].inventory_hostname }}"
+ datacenter: "{{ vcenter_datacenter }}"
+ cluster: "{{ vcenter_cluster }}"
+ resource_pool: "{{ vcenter_resource_pool }}"
+ folder: "/{{ vcenter_datacenter }}/vm/{{ vcenter_folder }}"
+ state: absent
+ force: true
+ with_items: "{{ groups['allnodes'] }}"
+
+ - name: Get current user home dir
+ shell: 'eval echo "~$USER"'
+ register: home_dir
+ - name: Set hosts files paths
+ set_fact:
+ home_hosts_file: "{{ home_dir.stdout_lines[0] + '/.ssh/config' }}"
+ system_hosts_file: "/etc/hosts"
+ - name: Check 'write' permissions for system hosts file
+ stat:
+ path: "{{ system_hosts_file }}"
+ register: stat_system_hosts
+
+ - name: Update system hosts file if writeable
+ lineinfile:
+ dest: "{{ system_hosts_file }}"
+ state: absent
+ regexp: "{{ hostvars[item].inventory_hostname }}"
+ create: true
+ with_items: "{{ groups['allnodes'] }}"
+ when: "stat_system_hosts.stat.writeable"
+ - name: Update user's SSH hosts file
+ lineinfile:
+ dest: "{{ home_hosts_file }}"
+ state: present
+ line: "Host obsolete-{{ item }}"
+ regexp: "Host {{ item }}"
+ create: true
+ mode: '644'
+ with_items: "{{ groups['allnodes'] }}"