summaryrefslogtreecommitdiffstats
path: root/playbooks/transient_cloud_instance.yml
blob: cffa7cac44f274cce8e3b97ba6dafa637867678d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# setup a transient instance in the Fedora infrastructure private cloud
#
# This playbook is used to spin up a transient instance for someone to test something. 
# In particular transient instances will all be terminated at least by the next 
# maint window for the cloud, but ideally people will terminate instances they 
# are done using. 
#
# If you have an application or longer term item that should always be around
# please use the persistent playbook instead.
#
# You MUST pass a name to it, ie: -e 'name=somethingdescriptive'
# You can optionally override defaults by passing any of the following: 
# image=imagename (default is centos70_x86_64)
# instance_type=some instance type (default is m1.small)
# root_auth_users='user1 user2 user3' (default is sysadmin-main group)
#
# Note: if you run this playbook with the same name= multiple times
# openstack is smart enough to just return the current ip of that instance
# and go on. This way you can re-run if you want to reconfigure it without
# reprovisioning it.
#

- name: check/create instance
  hosts: lockbox01.phx2.fedoraproject.org
  user: root
  gather_facts: False

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - /srv/private/ansible/vars.yml
   - /srv/web/infra/ansible/vars/fedora-cloud.yml
   - /srv/private/ansible/files/openstack/passwords.yml
  vars:
    image: "{{ centos70_x86_64 }}"
    instance_type: m1.small

  tasks:
  - name: fail when name is not provided
    fail: msg="Please specify the name of the instance"
    when: name is not defined

  - include: "{{ tasks }}/transient_cloud.yml"

- name: provision instance
  hosts: tmp_just_created
  gather_facts: True
  environment: 
    ANSIBLE_HOST_KEY_CHECKING: False

  vars_files: 
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  tasks:
  - name: install cloud-utils (yum)
    yum: pkg=cloud-utils state=present
    when: ansible_distribution_major_version|int < 22

  - name: install cloud-utils (dnf)
    command: dnf install -y cloud-utils
    when: ansible_distribution_major_version|int > 21 and ansible_cmdline.ostree is not defined

  - include: "{{ tasks }}/cloud_setup_basic.yml"

  handlers:
  - include: "{{ handlers }}/restart_services.yml"