Skip to content
Draft
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
17 changes: 17 additions & 0 deletions ansible/ci/inventory_IBM-Z.vpc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
plugin: ibm.cloudcollection.vpc_inventory
regions:
- us-east
#ibmcloud_api_key: "{{ lookup('env', 'IBM_CLOUD_S390X_API_KEY') }}"
ansible_host_type: name
fail_on_duplicate: false
compose:
ibm_cloud_vm: "true"
vm_arch: "tags | select('match', '^vm_arch:') | map('split', ':') | map('last') | first"
vm_config: "tags | select('match', '^vm_config:') | map('split', ':') | map('last') | first"
vm_image_family: "tags | select('match', '^vm_image_family:') | map('split', ':') | map('last') | first"
filters:
resource_group: 1a33a6a9bd6e498f8115e9b1064bfa97
keyed_groups:
- key: "tags | select('match', '^job_id:') | map('split', ':') | map('last') | first"
prefix: job_id
1 change: 1 addition & 0 deletions ansible/dev/inventory_IBM-Z.vpc.yml
35 changes: 5 additions & 30 deletions ansible/roles/create-vm/tasks/create-s390x-vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
zone: "{{ s390x.zone }}"
boot_volume:
- size: "{{ s390x.disk_size }}"
tags:
- "job_id:{{ job_id }}"
- "vm_config:{{ vm_config }}"
- "vm_image_family:{{ vm_family }}"
- "vm_arch:{{ vm_arch }}"
register: vsi

- name: Check for existing Floating IP
Expand All @@ -51,33 +56,3 @@
debug:
msg: "{{ vsi_name }} IP Address: {{ fip.resource.address }}"

always:
# regardless of success/failure of VM creation we want to add an entry
# to the inventory. VM creation can fail but a VM can be created (in a failed
# state) but without a record of it in the inventory we can leak VM instances
# in IBM cloud. Empty defaults in some variables here are to account for this.
- name: Add VSI to Ansible inventory
add_host:
name: "{{ vsi_name }}"
ansible_user: root
ansible_host: "{{ fip.resource.address | default('') }}"
groups:
- job_id_{{ job_id }}
- platform_{{ test_platform }}
- vm_arch_s390x
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
ansible_ssh_private_key_file: "{{ vm_ssh_key_file }}"
vm_config: "{{ vm_config }}"
vm_image_family: "{{ vm_family }}"
vm_collection_method: "{{ vm_collection_method }}"
vm_arch: "{{ vm_arch }}"
ibm_cloud_vm: true

- name: generate provisioner inventory file
template:
src: 'ibm-cloud-inventory.j2'
dest: "{{ ibm_output_inventory_file }}"
mode: '0644'
when:
- ibm_output_inventory_file != ""
delegate_to: localhost
Loading