copr: add a playbook to prepare builder in AWS

The `builderpb_nova_aws.yml` playbook doesn't spin up a new instance yet.
We currently have a one testing instance in AWS so the playbook
always provisions that particular instance.
This commit is contained in:
Jakub Kadlcik 2019-09-11 23:04:22 +02:00 committed by Pierre-Yves Chibon
parent 8b0df497f4
commit a1755eb2f0
3 changed files with 91 additions and 0 deletions

View file

@ -0,0 +1,44 @@
- name: check/create instance
hosts: 127.0.0.1
gather_facts: False
vars_files:
- vars.yml
- nova_cloud_vars.yml
vars:
keypair: buildsys
max_spawn_time: 1100
spawning_vm_user: "fedora"
image_name: "{{ builder_images.x86_64 }}"
tasks:
- name: so far we have only one instance in AWS so it will always be the same address
set_fact: builder_ip="34.254.223.48"
- name: add builder ip to the special group
local_action: add_host hostname="34.254.223.48" groupname=builder_temp_group
- name: provision builder
hosts: builder_temp_group
gather_facts: True
sudo: True
user: fedora
vars_files:
- vars.yml
- nova_cloud_vars.yml
vars:
ansible_python_interpreter: /usr/bin/python3
swap_file_path: "/swapfile"
swap_file_size_mb: 1024
tasks:
- include: "create_swap_file.yml"
when:
- prepare_base_image is defined
- include: "provision_builder_tasks.yml"
- include: "offloading_hack.yml"

View file

@ -0,0 +1,47 @@
- name: Create swap file
command: dd if=/dev/zero of={{ swap_file_path }} bs=1024 count={{ swap_file_size_mb }}k
creates="{{ swap_file_path }}"
tags:
- swap.file.create
- name: Change swap file permissions
file: path="{{ swap_file_path }}"
owner=root
group=root
mode=0600
tags:
- swap.file.permissions
- name: "Check swap file type"
command: file {{ swap_file_path }}
register: swapfile
tags:
- swap.file.mkswap
- name: Make swap file
command: "sudo mkswap {{ swap_file_path }}"
when: swapfile.stdout.find('swap file') == -1
tags:
- swap.file.mkswap
- name: Write swap entry in fstab
mount: name=none
src={{ swap_file_path }}
fstype=swap
opts=sw
passno=0
dump=0
state=present
tags:
- swap.fstab
- name: Mount swap
command: "swapon {{ swap_file_path }}"
when: ansible_swaptotal_mb < 1
tags:
- swap.file.swapon