|
8 | 8 | ssh_key_pub: ""
|
9 | 9 | inventory_file: ""
|
10 | 10 | download_node: "{{ lookup('env', 'DOWNLOAD_NODE') | default('', true) }}"
|
11 |
| - ami_id: "" |
12 | 11 | ami:
|
13 | 12 | x86_64:
|
14 | 13 | rhel-9-4: ami-044442bf4326c9933
|
|
41 | 40 | random_instance_type: "{{ lookup('env', 'instance_type') | default(instance_type[arch][instance_type_index], true) }}"
|
42 | 41 |
|
43 | 42 | - name: "get available zone for instance {{ random_instance_type }}"
|
44 |
| - shell: aws ec2 describe-instance-type-offerings --location-type availability-zone --filters="Name=instance-type,Values={{ random_instance_type }}" --query InstanceTypeOfferings | jq -r '.[0].Location' |
| 43 | + shell: | |
| 44 | + aws ec2 describe-instance-type-offerings \ |
| 45 | + --location-type availability-zone \ |
| 46 | + --filters="Name=instance-type,Values={{ random_instance_type }}" \ |
| 47 | + --query InstanceTypeOfferings | jq -r '.[0].Location' |
45 | 48 | register: ec2_zone
|
46 | 49 | when: "'rhel' not in test_os"
|
47 | 50 |
|
48 | 51 | - name: get subnet
|
49 |
| - amazon.aws.ec2_vpc_subnet_info: |
50 |
| - filters: |
51 |
| - "tag:Name": "kite-ci" |
52 |
| - "availabilityZone": "{{ ec2_zone.stdout }}" |
| 52 | + shell: | |
| 53 | + aws ec2 describe-subnets \ |
| 54 | + --output json \ |
| 55 | + --filters "Name=tag:Name,Values=kite-ci" "Name=availabilityZone,Values={{ ec2_zone.stdout }}" | \ |
| 56 | + jq -r ".Subnets[0].SubnetId" |
53 | 57 | register: ec2_vpc_subnet
|
54 | 58 | when: "'rhel' not in test_os"
|
55 | 59 |
|
56 | 60 | - set_fact:
|
57 |
| - subnet_id: "{{ ec2_vpc_subnet.subnets[0].subnet_id }}" |
| 61 | + subnet_id: "{{ ec2_vpc_subnet.stdout }}" |
58 | 62 | when: "'rhel' not in test_os"
|
59 | 63 |
|
60 | 64 | - name: get virtqe subnet
|
61 |
| - amazon.aws.ec2_vpc_subnet_info: |
62 |
| - filters: |
63 |
| - "tag:Name": "InternalA-virtqe" |
| 65 | + shell: | |
| 66 | + aws ec2 describe-subnets \ |
| 67 | + --output json \ |
| 68 | + --filters "Name=tag:Name,Values=InternalA-virtqe" | \ |
| 69 | + jq -r ".Subnets[0].SubnetId" |
64 | 70 | register: ec2_vpc_subnet
|
65 | 71 | when: '"rhel" in test_os'
|
66 | 72 |
|
67 | 73 | - set_fact:
|
68 |
| - subnet_id: "{{ ec2_vpc_subnet.subnets[0].subnet_id }}" |
| 74 | + subnet_id: "{{ ec2_vpc_subnet.stdout }}" |
69 | 75 | when: "'rhel' in test_os"
|
70 | 76 |
|
71 | 77 | - name: get security group
|
72 |
| - amazon.aws.ec2_security_group_info: |
73 |
| - filters: |
74 |
| - "tag:Name": "kite-ci" |
| 78 | + shell: | |
| 79 | + aws ec2 describe-security-groups \ |
| 80 | + --filters="Name=tag:Name,Values=kite-ci" \ |
| 81 | + --output json | \ |
| 82 | + jq -r ".SecurityGroups[0].GroupId" |
75 | 83 | register: ec2_security_group
|
76 | 84 | when: "'rhel' not in test_os"
|
77 | 85 |
|
78 | 86 | - set_fact:
|
79 |
| - group_id: "{{ ec2_security_group.security_groups[0].group_id }}" |
| 87 | + group_id: "{{ ec2_security_group.stdout }}" |
80 | 88 | when: "'rhel' not in test_os"
|
81 | 89 |
|
82 | 90 | - name: get virtqe security group
|
83 |
| - amazon.aws.ec2_security_group_info: |
84 |
| - filters: |
85 |
| - "tag:Name": "bootc-test" |
| 91 | + shell: | |
| 92 | + aws ec2 describe-security-groups \ |
| 93 | + --filters="Name=tag:Name,Values=bootc-test" \ |
| 94 | + --output json | \ |
| 95 | + jq -r ".SecurityGroups[0].GroupId" |
86 | 96 | register: ec2_security_group
|
87 | 97 | when: "'rhel' in test_os"
|
88 | 98 |
|
89 | 99 | - set_fact:
|
90 |
| - group_id: "{{ ec2_security_group.security_groups[0].group_id }}" |
| 100 | + group_id: "{{ ec2_security_group.stdout }}" |
91 | 101 | when: "'rhel' in test_os"
|
92 | 102 |
|
93 | 103 | - name: config ssh keypair used by test
|
94 |
| - amazon.aws.ec2_key: |
95 |
| - name: "kp-bootc-{{ random_num }}" |
96 |
| - key_material: "{{ lookup('file', ssh_key_pub) }}" |
97 |
| - tags: |
98 |
| - name: "bootc-test" |
| 104 | + shell: | |
| 105 | + aws ec2 import-key-pair \ |
| 106 | + --key-name "kp-bootc-{{ random_num }}" \ |
| 107 | + --public-key-material "fileb://{{ ssh_key_pub }}" \ |
| 108 | + --tag-specification 'ResourceType=key-pair,Tags=[{Key=Name,Value=bootc-test}]' |
99 | 109 |
|
100 | 110 | - name: generate ec2_run_instance script
|
101 | 111 | template:
|
|
112 | 122 | instance_json: "{{ result_instance.stdout | from_json }}"
|
113 | 123 |
|
114 | 124 | - name: wait for instance running
|
115 |
| - shell: aws ec2 describe-instances --instance-ids {{ instance_json.Instances[0].InstanceId }} --query 'Reservations[0].Instances[0].State.Name' --output text |
116 |
| - register: describe_result |
117 |
| - retries: 60 |
118 |
| - delay: 5 |
119 |
| - until: describe_result.stdout == "running" |
| 125 | + shell: | |
| 126 | + aws ec2 wait instance-running \ |
| 127 | + --instance-ids {{ instance_json.Instances[0].InstanceId }} |
120 | 128 |
|
121 | 129 | - name: get instance public ip
|
122 |
| - shell: aws ec2 describe-instances --instance-ids {{ instance_json.Instances[0].InstanceId }} --query 'Reservations[*].Instances[*].PublicIpAddress' --output text |
| 130 | + shell: | |
| 131 | + aws ec2 describe-instances \ |
| 132 | + --instance-ids {{ instance_json.Instances[0].InstanceId }} \ |
| 133 | + --query 'Reservations[*].Instances[*].PublicIpAddress' \ |
| 134 | + --output text |
123 | 135 | register: ip_result
|
124 | 136 | when: "'rhel' not in test_os"
|
125 | 137 |
|
|
128 | 140 | when: "'rhel' not in test_os"
|
129 | 141 |
|
130 | 142 | - name: get instance private ip
|
131 |
| - shell: aws ec2 describe-instances --instance-ids {{ instance_json.Instances[0].InstanceId }} --query 'Reservations[*].Instances[*].PrivateIpAddress' --output text |
| 143 | + shell: | |
| 144 | + aws ec2 describe-instances \ |
| 145 | + --instance-ids {{ instance_json.Instances[0].InstanceId }} \ |
| 146 | + --query 'Reservations[*].Instances[*].PrivateIpAddress' \ |
| 147 | + --output text |
132 | 148 | register: ip_result
|
133 | 149 | when: "'rhel' in test_os"
|
134 | 150 |
|
|
174 | 190 | option: instance_id
|
175 | 191 | value: "{{ instance_json.Instances[0].InstanceId }}"
|
176 | 192 | no_extra_spaces: true
|
177 |
| - |
178 |
| - - name: write AWS ami id to inventory file |
179 |
| - community.general.ini_file: |
180 |
| - path: "{{ inventory_file }}" |
181 |
| - section: cloud:vars |
182 |
| - option: ami_id |
183 |
| - value: "{{ ami_id }}" |
184 |
| - no_extra_spaces: true |
|
0 commit comments