Debian Codegraph @

ansible_collections/google/cloud/tests/integration/targets/connection_plugin/playbooks/setup.yml

raw
1 ---
2 - name: Setup test suite
3 hosts: localhost
4 connection: local
5 gather_facts: false
6 vars_files:
7 - ../vars.yml
8 environment:
9 GCP_SERVICE_ACCOUNT_FILE: "{{ gcp_cred_file }}"
10 GCP_AUTH_KIND: "{{ gcp_cred_kind }}"
11 GCP_PROJECT: "{{ gcp_project }}"
12 tasks:
13 - name: SETUP | Create SSH key pair
14 community.crypto.openssh_keypair:
15 path: "{{ ansible_ssh_private_key_file }}"
16 type: ed25519
17 register: _keypair
18
19 - name: SETUP | Create network
20 google.cloud.gcp_compute_network:
21 name: "{{ prefix }}"
22 auto_create_subnetworks: true
23 state: present
24 register: _network
25
26 - name: SETUP | Allow SSH through IAP
27 google.cloud.gcp_compute_firewall:
28 name: all-iap
29 state: present
30 source_ranges:
31 - 35.235.240.0/20
32 allowed:
33 - ip_protocol: tcp
34 ports:
35 - 22
36 network: "{{ _network }}"
37
38 - name: SETUP | Create instances
39 google.cloud.gcp_compute_instance:
40 name: "{{ prefix }}-{{ item.name }}"
41 machine_type: "{{ gcp_machine_type }}"
42 disks:
43 - auto_delete: true
44 boot: true
45 initialize_params:
46 source_image: "{{ gcp_disk_image }}"
47 disk_type: pd-standard
48 network_interfaces:
49 - network: "{{ _network }}"
50 metadata:
51 ssh-keys: "{{ ansible_ssh_user }}:{{ _keypair.public_key }}"
52 labels: "{{ item.labels | default({}) }}"
53 hostname: "{{ item.hostname | default(omit) }}"
54 zone: "{{ gcp_zone }}"
55 state: present
56 loop: "{{ sut }}"
57
58 - name: SETUP | Render dynamic inventory file
59 ansible.builtin.copy:
60 dest: ../test.gcp_compute.yml
61 content: "{{ lookup('template', '../templates/inventory.yml.j2') }}"
62 mode: preserve
63
64 - name: SETUP | Give time for instances to be up
65 ansible.builtin.pause:
66 seconds: 30