-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ansible-lint issues from prepare env files in tests. (#524)
* Fix `schema[tasks]: $[0] 'block' is a required property` lint issue in prep env tasks * Update ok to test command with dir structure changes * Fix prep env sanity tests
- Loading branch information
1 parent
2d2ad43
commit ddf9675
Showing
20 changed files
with
743 additions
and
751 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
67 changes: 67 additions & 0 deletions
67
tests/integration/targets/prepare_env/playbooks/cleanup.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,67 @@ | ||
--- | ||
- name: Clean up the environment | ||
hosts: localhost | ||
gather_facts: false | ||
tasks: | ||
- name: Include var file | ||
ansible.builtin.include_vars: ../vars/main.yml | ||
- name: Delete VM | ||
ignore_errors: true | ||
register: result | ||
nutanix.ncp.ntnx_vms: | ||
vm_uuid: "{{ vm.uuid }}" | ||
state: absent | ||
nutanix_host: "{{ ip }}" | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
validate_certs: false | ||
# # - name: Delete DR VM | ||
# # ntnx_vms: | ||
# # vm_uuid: '{{dr_vm.uuid }}' | ||
# # state: absent | ||
# # nutanix_host: "{{ ip }}" | ||
# # nutanix_username: "{{ username }}" | ||
# # nutanix_password: "{{ password }}" | ||
# # validate_certs: False | ||
- name: Delete overlay | ||
register: result | ||
ignore_errors: true | ||
nutanix.ncp.ntnx_subnets: | ||
state: absent | ||
nutanix_host: "{{ ip }}" | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
validate_certs: false | ||
subnet_uuid: "{{ item }}" | ||
loop: | ||
- "{{ overlay.uuid }}" | ||
- name: Delete vpc | ||
register: result | ||
ignore_errors: true | ||
nutanix.ncp.ntnx_vpcs: | ||
state: absent | ||
nutanix_host: "{{ ip }}" | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
validate_certs: false | ||
vpc_uuid: "{{ vpc.uuid }}" | ||
- name: Delete subnets | ||
ignore_errors: true | ||
register: result | ||
nutanix.ncp.ntnx_subnets: | ||
state: absent | ||
nutanix_host: "{{ ip }}" | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
validate_certs: false | ||
subnet_uuid: "{{ item }}" | ||
loop: | ||
- "{{ external_nat_subnet.uuid }}" | ||
- "{{ static.uuid }}" | ||
|
||
- name: Delete downloaded disk file | ||
ignore_errors: true | ||
register: result | ||
ansible.builtin.file: | ||
path: "{{ disk_image.dest }}" | ||
state: absent |
212 changes: 212 additions & 0 deletions
212
tests/integration/targets/prepare_env/playbooks/prepare_env.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,212 @@ | ||
--- | ||
- name: Prepare the environment | ||
hosts: localhost | ||
gather_facts: false | ||
|
||
tasks: | ||
- name: Include var file | ||
ansible.builtin.include_vars: ../vars/main.yml | ||
- name: Set environment variables | ||
ansible.builtin.set_fact: | ||
ip: "{{lookup('env', 'NUTANIX_HOST') }}" | ||
username: "{{lookup('env', 'NUTANIX_USERNAME') }}" | ||
password: "{{lookup('env', 'NUTANIX_PASSWORD') }}" | ||
recovery_site_ip: "{{lookup('env', 'NUTANIX_DR_SITE')}}" | ||
validate_certs: false | ||
- name: Insert credentials block to vars | ||
ansible.builtin.blockinfile: | ||
path: ../vars/main.yml | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK insertion 0" | ||
block: | | ||
ip: "{{lookup('env', 'NUTANIX_HOST') }}" | ||
username: "{{lookup('env', 'NUTANIX_USERNAME') }}" | ||
password: "{{lookup('env', 'NUTANIX_PASSWORD') }}" | ||
recovery_site_ip: "{{lookup('env', 'NUTANIX_DR_SITE') }}" | ||
validate_certs: false | ||
- name: Create external subnet with NAT | ||
nutanix.ncp.ntnx_subnets: | ||
state: present | ||
nutanix_host: "{{ ip }}" | ||
validate_certs: false | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
name: "{{external_nat_subnets[0].name}}" | ||
external_subnet: | ||
vlan_id: "{{external_nat_subnets[0].vlan_id}}" | ||
enable_nat: true | ||
cluster: | ||
name: "{{ cluster.name }}" | ||
ipam: | ||
network_ip: "{{ external_nat_subnets[0].network_ip }}" | ||
network_prefix: "{{ external_nat_subnets[0].network_prefix }}" | ||
gateway_ip: "{{ external_nat_subnets[0].gateway_ip_address }}" | ||
ip_pools: | ||
- start_ip: "{{ external_nat_subnets[0].dhcp.start_address }}" | ||
end_ip: "{{ external_nat_subnets[0].dhcp.end_address }}" | ||
register: result | ||
- name: Insert external subnet configuration block to vars | ||
ansible.builtin.blockinfile: | ||
path: ../vars/main.yml | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK insertion 1" | ||
block: | | ||
external_nat_subnet: | ||
name: "{{external_nat_subnets[0].name}}" | ||
uuid: "{{result.subnet_uuid}}" | ||
- name: Create min VPC with external_subnet uuid | ||
nutanix.ncp.ntnx_vpcs: | ||
validate_certs: false | ||
state: present | ||
wait: true | ||
nutanix_host: "{{ ip }}" | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
name: "{{vpc_name}}" | ||
external_subnets: | ||
- subnet_uuid: "{{ result.subnet_uuid }}" | ||
register: result | ||
|
||
- name: Insert VPC configuration block to vars | ||
ansible.builtin.blockinfile: | ||
path: ../vars/main.yml | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK insertion 2" | ||
block: | | ||
vpc: | ||
name: "{{vpc_name}}" | ||
uuid: "{{result.vpc_uuid}}" | ||
- name: Create vlan subnet with IPAM | ||
nutanix.ncp.ntnx_subnets: | ||
state: present | ||
nutanix_host: "{{ ip }}" | ||
wait: true | ||
validate_certs: false | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
name: "{{static_subnet_name}}" | ||
vlan_subnet: | ||
vlan_id: 373 | ||
virtual_switch: | ||
name: vs0 | ||
cluster: | ||
name: "{{ cluster.name }}" | ||
ipam: | ||
network_ip: 10.30.30.0 | ||
network_prefix: 24 | ||
gateway_ip: 10.30.30.254 | ||
ip_pools: | ||
- start_ip: 10.30.30.10 | ||
end_ip: 10.30.30.90 | ||
register: result | ||
|
||
- name: Insert vlan subnet configuration block to var file | ||
ansible.builtin.blockinfile: | ||
path: ../vars/main.yml | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK insertion 3" | ||
block: | | ||
static: | ||
name: "{{static_subnet_name}}" | ||
uuid: "{{result.subnet_uuid}}" | ||
network_ip: 10.30.30.0 | ||
network_prefix: 24 | ||
gateway_ip: 10.30.30.254 | ||
- name: Include var file | ||
ansible.builtin.include_vars: ../vars/main.yml | ||
- name: Create overlay Subnet with minimum requirements | ||
nutanix.ncp.ntnx_subnets: | ||
state: present | ||
nutanix_host: "{{ ip }}" | ||
validate_certs: false | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
name: "{{overlay_subnet.name}}" | ||
overlay_subnet: | ||
vpc: | ||
uuid: "{{ vpc.uuid }}" | ||
ipam: | ||
network_ip: "{{overlay_subnet.network_ip}}" | ||
network_prefix: "{{overlay_subnet.network_prefix}}" | ||
gateway_ip: "{{overlay_subnet.gateway_ip}}" | ||
register: result | ||
|
||
- name: Insert overlay subnet configuration block to var file | ||
ansible.builtin.blockinfile: | ||
path: ../vars/main.yml | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK insertion 4" | ||
block: | | ||
overlay: | ||
name: "{{overlay_subnet.name}}" | ||
uuid: "{{result.subnet_uuid}}" | ||
- name: Create VM with overlay subnet | ||
nutanix.ncp.ntnx_vms: | ||
state: present | ||
nutanix_host: "{{ ip }}" | ||
nutanix_username: "{{ username }}" | ||
nutanix_password: "{{ password }}" | ||
validate_certs: false | ||
name: "{{vm_name}}" | ||
cluster: | ||
uuid: "{{ cluster.uuid }}" | ||
networks: | ||
- is_connected: true | ||
subnet: | ||
name: "{{overlay_subnet.name}}" | ||
private_ip: "{{overlay_subnet.private_ip}}" | ||
register: result | ||
|
||
- name: Insert vm configuration block to var file | ||
ansible.builtin.blockinfile: | ||
path: ../vars/main.yml | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK insertion 5" | ||
block: | | ||
vm: | ||
name: "{{vm_name}}" | ||
uuid: "{{result.vm_uuid}}" | ||
# - name: create VM with static subnet for dr tests | ||
# nutanix.ncp.ntnx_vms: | ||
# state: present | ||
# nutanix_host: "{{ ip }}" | ||
# nutanix_username: "{{ username }}" | ||
# nutanix_password: "{{ password }}" | ||
# validate_certs: false | ||
# name: "{{dr_vm_name}}" | ||
# categories: | ||
# Environment: | ||
# - Staging | ||
# - Testing | ||
# cluster: | ||
# uuid: "{{ cluster.uuid }}" | ||
# networks: | ||
# - is_connected: true | ||
# subnet: | ||
# name: "{{static_subnet_name}}" | ||
# vcpus: 1 | ||
# cores_per_vcpu: 1 | ||
# memory_gb: 1 | ||
# register: result | ||
|
||
# - name: Insert vm configuration block to var file | ||
# ansible.builtin.blockinfile: | ||
# path: ../vars/main.yml | ||
# marker: "# {mark} ANSIBLE MANAGED BLOCK insertion 6" | ||
# block: | | ||
# dr_vm: | ||
# name: "{{dr_vm_name}}" | ||
# uuid: "{{result.vm_uuid}}" | ||
|
||
- name: Downloading disk image for image related tests | ||
ansible.builtin.get_url: | ||
mode: "0644" | ||
url: "{{ disk_image.url }}" | ||
dest: "{{ disk_image.dest }}" | ||
# # - name: create address group for network security policy related tests | ||
# # nutanix.ncp.ntnx_address_groups: | ||
# # state: present | ||
# # name: dest | ||
# # desc: dest | ||
# # subnets: | ||
# # - network_ip: "10.1.1.0" | ||
# # network_prefix: 24 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.