summaryrefslogtreecommitdiffstats
path: root/playbooks/aws/openshift-cluster/build_ami.yml
blob: fc11205d8acbeea7c40830970950178ac77694c3 (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
69
70
71
72
73
74
75
76
77
78
---
- hosts: localhost
  connection: local
  gather_facts: no
  tasks:
  - name: Require openshift_aws_base_ami
    fail:
      msg: "A base AMI is required for AMI building.  Please ensure  `openshift_aws_base_ami` is defined."
    when: openshift_aws_base_ami is undefined

  - name: "Alert user to variables needed and their values - {{ item.name }}"
    debug:
      msg: "{{ item.msg }}"
    with_items:
    - name: openshift_aws_clusterid
      msg: "openshift_aws_clusterid={{ openshift_aws_clusterid | default('default') }}"
    - name: openshift_aws_region
      msg: "openshift_aws_region={{ openshift_aws_region | default('us-east-1') }}"

  - name: create an instance and prepare for ami
    include_role:
      name: openshift_aws
      tasks_from: build_ami.yml
    vars:
      openshift_aws_node_group_type: compute

  - name: fetch newly created instances
    ec2_remote_facts:
      region: "{{ openshift_aws_region | default('us-east-1') }}"
      filters:
        "tag:Name": "{{ openshift_aws_base_ami_name | default('ami_base') }}"
        instance-state-name: running
    register: instancesout
    retries: 20
    delay: 3
    until: instancesout.instances|length > 0

  - name: wait for ssh to become available
    wait_for:
      port: 22
      host: "{{ instancesout.instances[0].public_ip_address }}"
      timeout: 300
      search_regex: OpenSSH

  - name: add host to nodes
    add_host:
      groups: nodes
      name: "{{ instancesout.instances[0].public_dns_name }}"

  - name: set the user to perform installation
    set_fact:
      ansible_ssh_user: root

- name: normalize groups
  include: ../../byo/openshift-cluster/initialize_groups.yml

- name: run the std_include
  include: ../../common/openshift-cluster/evaluate_groups.yml

- name: run the std_include
  include: ../../common/openshift-cluster/initialize_facts.yml

- name: run the std_include
  include: ../../common/openshift-cluster/initialize_openshift_repos.yml

- name: install node config
  include: ../../common/openshift-node/config.yml

- hosts: localhost
  connection: local
  become: no
  tasks:
  - name: seal the ami
    include_role:
      name: openshift_aws
      tasks_from: seal_ami.yml
    vars:
      openshift_aws_ami_name: "openshift-gi-{{ lookup('pipe', 'date +%Y%m%d%H%M')}}"