Skip to content

Commit

Permalink
Use Env for AWS region, fix 2.8 deprecation warnings (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontleon authored May 28, 2019
1 parent c112837 commit c927183
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 32 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ This repo provides some ansible to bring up an Origin cluster of the specified v
## Use
* copy `config.yml.example` to `config.yml` and edit desired options
* Set `ec2_install: true` in config.yml to install on ec2 or `ec2_install: false` to install locally
* For EC2 you will want to set the following environment variables for authentication:
* For EC2 you will want to set the following environment variables for authentication and region:
* AWS_ACCESS_KEY_ID
* AWS_SECRET_ACCESS_KEY
* AWS_REGION
* For EC2 ensure your private key exists at the location referenced by ec2_private_key_file in config.yml
* Run `ansible-playbook deploy.yml`

Expand Down
2 changes: 0 additions & 2 deletions ansible/ec2_terminate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
filters:
"tag:Name": "{{ ansible_user }}-origin3-dev"
"tag:creator_arn": "{{ caller_facts.arn }}"
region: "{{ ec2_region }}"
register: ec2_metadata

- set_fact:
Expand All @@ -30,6 +29,5 @@
module: ec2
instance_ids: "{{ instances }}"
state: absent
region: "{{ ec2_region }}"
when: (proceed.user_input is defined and proceed.user_input == "yes") or
ec2_force_terminate_instances == "true"
1 change: 0 additions & 1 deletion ansible/roles/ec2_provision/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ ec2_repo_create: true
ec2_instance_type: m4.medium
ec2_instance_disk_size: 32
ec2_rhel_version: 7.6
ec2_region: us-east-1
ec2_vpc_name: origin3-dev
ec2_vpc_cidr: 10.0.0.0/16
ec2_subnet_cidr: 10.0.1.0/24
Expand Down
13 changes: 3 additions & 10 deletions ansible/roles/ec2_provision/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
- ansible_os_family == "RedHat"
- python == "python"
- not(ansible_distribution == 'Fedora')
- ec2_repo_create
- ec2_repo_create|bool

- name: Install boto and boto3 through yum/dnf
package:
Expand All @@ -41,13 +41,12 @@
become: 'true'
when:
- ansible_os_family == "RedHat"
- ec2_repo_create
- ec2_repo_create|bool

- name: Create VPC
ec2_vpc_net:
name: "{{ ec2_vpc_name }}"
cidr_block: "{{ ec2_vpc_cidr }}"
region: "{{ ec2_region }}"
tags:
creator: origin3-dev
register: ec2_vpc
Expand All @@ -57,23 +56,20 @@
state: present
vpc_id: "{{ ec2_vpc.vpc.id }}"
cidr: "{{ ec2_subnet_cidr }}"
region: "{{ ec2_region }}"
resource_tags:
creator: origin3-dev
register: ec2_subnet

- name: Create VPC Internet Gateway
ec2_vpc_igw:
vpc_id: "{{ ec2_vpc.vpc.id }}"
region: "{{ ec2_region }}"
tags:
Name: origin3-dev
register: ec2_igw

- name: Create VPC Routing Table
ec2_vpc_route_table:
vpc_id: "{{ ec2_vpc.vpc.id }}"
region: "{{ ec2_region }}"
tags:
Name: origin3-dev
subnets:
Expand All @@ -87,7 +83,6 @@
name: origin3-dev
description: origin3-dev
vpc_id: "{{ ec2_vpc.vpc.id }}"
region: "{{ ec2_region }}"
rules_egress:
- proto: "all"
from_port: "0"
Expand Down Expand Up @@ -118,7 +113,6 @@
- name: Get Red Hat AMI List
ec2_ami_facts:
owners: 309956199498
region: "{{ ec2_region }}"
register: ami_list
when: not(ec2_ami is defined)

Expand All @@ -143,7 +137,6 @@
group: origin3-dev
image: "{{ ec2_ami }}"
count: 1
region: "{{ ec2_region }}"
vpc_subnet_id: "{{ ec2_subnet.subnet.id }}"
assign_public_ip: yes
instance_tags:
Expand Down Expand Up @@ -171,7 +164,7 @@
delay: 20
timeout: 300
register: result
until: result|succeeded
until: result is succeeded
retries: 5

- name: Ensure SSH homedir is present
Expand Down
31 changes: 18 additions & 13 deletions ansible/roles/openshift_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,28 @@

- name: Get localhost facts
setup:
when: ec2_install
when: ec2_install|bool
delegate_to: localhost

- set_fact:
openshift_setup_build_type: "mac"
openshift_setup_client_ext: "zip"
when:
- ansible_os_family == "Darwin"
- ec2_install
- ec2_install|bool

- set_fact:
openshift_setup_build_type: "linux-64bit"
openshift_setup_client_ext: "tar.gz"
when:
- (ansible_os_family == "RedHat") or (ansible_distribution == "Ubuntu") or (ansible_distribution == "Archlinux")
- ec2_install
- ec2_install|bool

- file:
path: "{{ openshift_setup_client_tools_dir }}"
state: directory
mode: 0755
when: ec2_install
when: ec2_install|bool
delegate_to: localhost

- name: Get client binary for Mac on localhost
Expand All @@ -87,7 +87,7 @@
when:
- openshift_setup_client_ext=="zip"
- not(openshift_setup_use_local_oc_client)
- ec2_install
- ec2_install|bool
delegate_to: localhost

- name: Get client binary for Linux on localhost
Expand All @@ -103,12 +103,12 @@
when:
- openshift_setup_client_ext=="tar.gz"
- not(openshift_setup_use_local_oc_client)
- ec2_install
- ec2_install|bool
delegate_to: localhost

- name: Restore ec2 host facts
setup:
when: ec2_install
when: ec2_install|bool

- name: Install requirements through pip
pip:
Expand Down Expand Up @@ -157,7 +157,8 @@
docker_image:
name: "{{ item.img }}"
state: present
force: yes
force_source: yes
source: pull
tag: "{{ item.tag }}"
with_items:
- "{{ openshift_setup_docker_images.group1 }}"
Expand All @@ -166,7 +167,8 @@
docker_image:
name: "{{ item.img }}"
state: present
force: yes
force_source: yes
source: pull
tag: "{{ item.tag }}"
with_items:
- "{{ openshift_setup_docker_images.group2 }}"
Expand All @@ -179,7 +181,8 @@
docker_image:
name: "{{ item.img }}"
state: present
force: yes
force_source: yes
source: pull
tag: "{{ item.tag }}"
with_items:
- "{{ openshift_setup_docker_images.group3 }}"
Expand All @@ -191,7 +194,8 @@
docker_image:
name: "{{ item.img }}"
state: present
force: yes
force_source: yes
source: pull
tag: "{{ item.tag }}"
with_items:
- "{{ openshift_setup_docker_images.group4 }}"
Expand All @@ -204,7 +208,8 @@
docker_image:
name: "{{ item.img }}"
state: present
force: yes
force_source: yes
source: pull
tag: "{{ item.tag }}"
with_items:
- "{{ openshift_setup_docker_images.group5 }}"
Expand Down Expand Up @@ -406,5 +411,5 @@

- name: Auto login remotely as {{ openshift_setup_user }}
shell: "oc login -u {{ openshift_setup_user }} -p {{ openshift_setup_user_password }} https://{{ openshift_setup_hostname }}:8443 --insecure-skip-tls-verify=true"
when: openshift_setup_remote_auto_login
when: openshift_setup_remote_auto_login|bool
delegate_to: localhost
1 change: 0 additions & 1 deletion config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ec2_force_terminate_instances: false
ec2_instance_type: m4.large
ec2_key: libra
ec2_private_key_file: ~/.ssh/libra.pem
ec2_region: us-east-1
ec2_subnet_cidr: 10.0.1.0/24
ec2_vpc_cidr: 10.0.0.0/16
ec2_vpc_name: origin3-dev
Expand Down
4 changes: 2 additions & 2 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- config.yml

- import_playbook: ansible/local.yml
when: not(ec2_install)
when: not(ec2_install)|bool

- import_playbook: ansible/ec2.yml
when: ec2_install
when: ec2_install|bool
4 changes: 2 additions & 2 deletions terminate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- config.yml

- import_playbook: ansible/local_terminate.yml
when: not(ec2_install)
when: not(ec2_install)|bool

- import_playbook: ansible/ec2_terminate.yml
when: ec2_install
when: ec2_install|bool

0 comments on commit c927183

Please sign in to comment.