-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ondra Machacek <omachace@redhat.com>
- Loading branch information
1 parent
ecee0a2
commit 782dd38
Showing
15 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: Gather infomation about VMware | ||
hosts: all | ||
gather_facts: false | ||
|
||
roles: | ||
- role: cloud.vmware_ops.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Gather information from vcenter | ||
|
||
A role that gather information from vcenter. | ||
|
||
## Requirements | ||
|
||
N/A | ||
|
||
## Role Variables | ||
### Auth | ||
- **info_username**: | ||
- The vSphere vCenter username. | ||
|
||
- **info_password**: | ||
- The vSphere vCenter password. | ||
|
||
- **info_hostname**: | ||
- The hostname or IP address of the vSphere vCenter. | ||
|
||
- **info_validate_certs** | ||
- Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. | ||
|
||
### Appliance | ||
- **info_appliance_gather** | ||
- Define the sections of the appliance to gather. By default we gather all appliance information. | ||
|
||
- **info_appliance_file** | ||
- File where to store the gathered data. Default is `/tmp/appliance-{random}` | ||
|
||
### License | ||
- **info_license_file** | ||
- File where to store the gathered data. Default is `/tmp/appliance-{random}` | ||
|
||
### Cluster | ||
- **info_cluster_file** | ||
- File where to store the gathered data. Default is `/tmp/appliance-{random}` | ||
|
||
### Storage | ||
- **info_storage_file** | ||
- File where to store the gathered data. Default is `/tmp/appliance-{random}` | ||
|
||
### Guest | ||
- **info_guest_file** | ||
- File where to store the gathered data. Default is `/tmp/appliance-{random}` | ||
|
||
## Dependencies | ||
|
||
- community.vmware | ||
- vmware.vmware | ||
- vmware.vmware_rest | ||
|
||
## Example Playbook | ||
```yaml | ||
--- | ||
- name: Manage vmware operation visibility | ||
hosts: all | ||
gather_facts: false | ||
|
||
vars: | ||
info_hostname: "vcenterhostname" | ||
info_username: "username" | ||
info_password: "password" | ||
|
||
info_license: true | ||
info_storage: true | ||
info_appliance: true | ||
|
||
roles: | ||
- role: cloud.vmware_ops.info | ||
``` | ||
## License | ||
GNU General Public License v3.0 or later | ||
See [LICENCE](https://github.com/ansible-collections/cloud.aws_troubleshooting/blob/main/LICENSE) to see the full text. | ||
## Author Information | ||
- Ansible Cloud Content Team |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
info_validate_certs: true | ||
info_hostport: "{{ info_hostname + ':' + info_port if info_port is defined else info_hostname }}" | ||
|
||
# Appliance | ||
info_appliance_gather: all | ||
info_appliance_file: "/tmp/appliance-{{ lookup('community.general.random_string', special=false) }}" | ||
|
||
# Cluster | ||
info_datacenters: [] | ||
info_cluster_file: "/tmp/cluster-{{ lookup('community.general.random_string', special=false) }}" | ||
|
||
# Guest | ||
info_guest_file: "/tmp/guest-{{ lookup('community.general.random_string', special=false) }}" | ||
|
||
# License | ||
info_license_file: "/tmp/license-{{ lookup('community.general.random_string', special=false) }}" | ||
|
||
# Storage | ||
info_storage_file: "/tmp/storage-{{ lookup('community.general.random_string', special=false) }}" | ||
|
||
# Enable | ||
info_guest: false | ||
info_cluster: false | ||
info_license: false | ||
info_storage: false | ||
info_appliance: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- name: Fetch the appliance information | ||
vmware.vmware.appliance_info: | ||
hostname: "{{ info_hostname }}" | ||
username: "{{ info_username }}" | ||
password: "{{ info_password }}" | ||
port: "{{ info_port | d(omit) }}" | ||
validate_certs: "{{ info_validate_certs }}" | ||
gather: "{{ info_appliance_gather }}" | ||
register: __apliance | ||
|
||
- name: Create JSON file from fetched data | ||
ansible.builtin.copy: | ||
content: "{{ __apliance | map(attribute='appliance') | to_json }}" | ||
dest: "{{ info_appliance_file }}" | ||
mode: "0644" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
- name: Get clusters | ||
vmware.vmware_rest.vcenter_cluster_info: | ||
vcenter_hostname: "{{ info_hostport }}" | ||
vcenter_username: "{{ info_username }}" | ||
vcenter_password: "{{ info_password }}" | ||
vcenter_validate_certs: "{{ info_validate_certs }}" | ||
register: __clusters | ||
tags: | ||
- cluster | ||
|
||
- name: Get cluster info | ||
community.vmware.vmware_cluster_info: | ||
hostname: "{{ info_hostname }}" | ||
username: "{{ info_username }}" | ||
password: "{{ info_password }}" | ||
port: "{{ info_port | d(omit) }}" | ||
validate_certs: "{{ info_validate_certs }}" | ||
cluster_name: "{{ item.name }}" | ||
schema: vsphere | ||
properties: | ||
- name | ||
- configuration.dasConfig.enabled | ||
- summary.totalCpu | ||
loop: "{{ __clusters.value }}" | ||
register: __clusters_info | ||
tags: | ||
- cluster | ||
|
||
- name: Create JSON file from fetched data | ||
ansible.builtin.copy: | ||
content: "{{ __clusters_info.results | map(attribute='clusters') | to_json }}" | ||
dest: "{{ info_cluster_file }}" | ||
mode: "0644" | ||
tags: | ||
- cluster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- name: Guest info | ||
vmware.vmware.guest_info: | ||
hostname: "{{ info_hostname }}" | ||
username: "{{ info_username }}" | ||
password: "{{ info_password }}" | ||
port: "{{ info_port | d(omit) }}" | ||
validate_certs: "{{ info_validate_certs }}" | ||
register: __guests | ||
|
||
- name: Create JSON file from fetched data | ||
ansible.builtin.copy: | ||
content: "{{ __guests | to_json }}" | ||
dest: "{{ info_guest_file }}" | ||
mode: "0644" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- name: Fetch the license information | ||
vmware.vmware.license_info: | ||
hostname: "{{ info_hostname }}" | ||
username: "{{ info_username }}" | ||
password: "{{ info_password }}" | ||
port: "{{ info_port | d(omit) }}" | ||
validate_certs: "{{ info_validate_certs }}" | ||
register: __license | ||
|
||
- name: Create JSON file from fetched data | ||
ansible.builtin.copy: | ||
content: "{{ __license.licenses | to_json }}" | ||
dest: "{{ info_license_file }}" | ||
mode: "0644" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
- name: License info | ||
ansible.builtin.include_tasks: license_info.yml | ||
when: info_license | ||
tags: | ||
- license | ||
|
||
- name: Appliance info | ||
ansible.builtin.include_tasks: appliance_info.yml | ||
when: info_appliance | ||
tags: | ||
- appliance | ||
|
||
- name: Guest info | ||
ansible.builtin.include_tasks: guest_info.yml | ||
when: info_guest | ||
tags: | ||
- guest | ||
|
||
- name: Cluster info | ||
ansible.builtin.include_tasks: cluster_info.yml | ||
when: info_cluster | ||
tags: | ||
- cluster | ||
|
||
- name: Storage info | ||
ansible.builtin.include_tasks: storage_info.yml | ||
when: info_storage | ||
tags: | ||
- storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- name: Gather storage policy | ||
community.vmware.vmware_vm_storage_policy_info: | ||
hostname: "{{ info_hostname }}" | ||
username: "{{ info_username }}" | ||
password: "{{ info_password }}" | ||
port: "{{ info_port | d(omit) }}" | ||
validate_certs: "{{ info_validate_certs }}" | ||
register: __storage_policy | ||
|
||
- name: Create JSON file from fetched data | ||
ansible.builtin.copy: | ||
content: "{{ __storage_policy.spbm_profiles | to_json }}" | ||
dest: "{{ info_storage_file }}" | ||
mode: "0644" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[ | ||
{ | ||
"httpRequest": { | ||
"method": "POST", | ||
"path": "/rest/com/vmware/cis/session" | ||
}, | ||
"httpResponse": { | ||
"statusCode": 200, | ||
"body": {"value": "72300ca9ff16c5743fa0a6328c8570ce"} | ||
} | ||
}, | ||
{ | ||
"httpRequest": { | ||
"method" : "GET", | ||
"path" : "/api/vcenter/cluster" | ||
}, | ||
"httpResponse": { | ||
"statusCode": 200, | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"body": "[{\"drs_enabled\":false,\"cluster\":\"domain-c2808\",\"name\":\"DC0_C0\",\"ha_enabled\":false}]" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- hosts: localhost | ||
gather_facts: no | ||
collections: | ||
- community.general | ||
vars_files: | ||
- vars.yml | ||
|
||
tasks: | ||
- name: Vcsim | ||
ansible.builtin.import_role: | ||
name: prepare_soap | ||
|
||
- name: Vcsim | ||
ansible.builtin.import_role: | ||
name: prepare_rest | ||
|
||
- name: Import info role | ||
ansible.builtin.import_role: | ||
name: info_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
source ../init.sh | ||
exec ansible-playbook run.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- name: Info role | ||
ansible.builtin.import_role: | ||
name: cloud.vmware_ops.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
info_hostname: "127.0.0.1" | ||
info_username: "user" | ||
info_password: "pass" | ||
info_port: "8989" | ||
info_hostport: "127.0.0.1:1080" | ||
info_validate_certs: false | ||
|
||
mock_file: "info_test" | ||
|
||
info_cluster: true |