copr-be: unify spot/on-demand playbooks

This commit is contained in:
Pavel Raiskup 2021-07-26 14:27:39 +02:00
parent 2400b318f4
commit 25dd467819
4 changed files with 5 additions and 50 deletions

View file

@ -28,7 +28,7 @@
volume_size: 160
tasks:
- include: "spinup_aws_spot_task.yml"
- include: "spinup_aws_task.yml"
- name: provision builder

View file

@ -23,7 +23,7 @@
image_name: "{{ builder_images[arch] }}"
tasks:
- include: "spinup_aws_spot_task.yml"
- include: "spinup_aws_task.yml"
- name: provision builder

View file

@ -1,48 +0,0 @@
---
- debug: msg="vm_name={{ vm_name }}"
- name: random subnet to overcome datacenter failures
set_fact: subnet_id={{ item }}
with_random_choice: "{{ aws_arch_subnets[arch] }}"
- name: Launch instance
ec2:
key_name: "{{ keypair }}"
group: "{{ security_group }}"
instance_type: "{{ instance_type }}"
image: "{{ image_name }}"
wait: true
region: "{{ aws_region }}"
# both x86_64 and aarch64 arches can be allocated in us-east-1c
vpc_subnet_id: "{{ subnet_id }}"
assign_public_ip: yes
instance_tags:
FedoraGroup: copr
CoprPurpose: builder
CoprInstance: "{% if devel %}devel{% else %}production{% endif %}"
Name: "{{ vm_name }}"
arch: "{{ arch }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
volumes: "{% if instance_volumes is defined %}{{ instance_volumes }}{% else %}[]{% endif %}"
spot_price: "{{ spot_price }}"
instance_initiated_shutdown_behavior: terminate
register: ec2
- name: Add new instance to host group
add_host:
hostname: "{{ item.public_ip }}"
groupname: builder_temp_group
loop: "{{ ec2.instances }}"
- set_fact: builder_ip={{ ec2.instances[0].public_ip }}
- debug: msg="VM_IP={{ builder_ip }}"
- name: wait for he host to be hot
local_action: wait_for host={{ builder_ip }} port=22 delay=1 timeout={{ max_spawn_time }}
- name: wait until ssh is available
local_action: shell false; until [ "$?" -eq "0" ]; do sleep 2; ssh -o PasswordAuthentication=no {{ spawning_vm_user|default('fedora') }}@{{ builder_ip }} 'echo foobar' 2>/dev/null; done
async: 600
poll: 2

View file

@ -1,3 +1,4 @@
---
- debug: msg="vm_name={{ vm_name }}"
- name: random subnet to overcome datacenter failures
@ -24,6 +25,8 @@
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
volumes: "{% if instance_volumes is defined %}{{ instance_volumes }}{% else %}[]{% endif %}"
spot_price: "{{ spot_price if spot_price is defined else '' }}"
instance_initiated_shutdown_behavior: terminate
register: ec2
- name: Add new instance to host group