Skip to content

Commit

Permalink
Merge master dev (#54)
Browse files Browse the repository at this point in the history
* Updated to use summit labels (#47)

* Adds macOS support for local environment (#49)

* Successful run local on macOS, postgres/python bind worked.

* Reverted asbcli up to use openshift_url variable

* Update README

* Add note 'socat' needs to be installed on mac

* Fix for install asb pip requirements

* Update README for 2 local directories

* README tweak

* Change to pip install docker instead of the older docker-py (#50)

* Revert "Updated to use summit labels (#47)"

This reverts commit 3c7e187.

* Minor fixes necessary after merging master.

* Adapting vars_prompt to ec2 and mac.
  • Loading branch information
cfchase authored Jun 1, 2017
1 parent f74b511 commit dc144d4
Show file tree
Hide file tree
Showing 29 changed files with 315 additions and 119 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
my_vars.yml
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ These playbooks will:


### Local and EC-2 deployment options
* To view individual Readme documents for these two options click below
* [Local deployment](local/README.md)
* To view individual Readme documents for these options click below
* [Local Linux deployment](local/linux/README.md)
* [Local macOS deployment](local/mac/README.md)
* [EC-2 deployment](ec2/README.md)
2 changes: 1 addition & 1 deletion ansible/display_ec2_instance_information.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
SSH Key Name: {{ ssh_key_name }}
Region: {{ aws_region }}
Next steps:
1) Visit https://apiserver-service-catalog.{{ openshift_hostname }}
1) Visit https://apiserver-service-catalog.{{ openshift_routing_suffix }}
2) Accept the certificate
3) Visit https://{{ openshift_hostname }}:8443 for the console
4) Provision a RDS APB into awsdemo project
Expand Down
11 changes: 11 additions & 0 deletions ansible/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ aws_ami_id: ami-b63769a1

instance_type: c4.4xlarge

# For local setup, especially on Mac the openshift_hostname will be
# different from the routing_suffix.
# We expect the openshift_hostname for Mac to be the public IP
# This is needed so oc cluster up and can ensure it's listening
# on the correct interface.
#
# For ec2 runs this is less important to differentiate and we expect
# openshift_hostname and openshift_routing_suffix to be the same
#
openshift_hostname: "{{target_subdomain}}.{{target_dns_zone}}"
openshift_routing_suffix: "{{target_subdomain}}.{{target_dns_zone}}"
openshift_url: "{{ openshift_hostname }}:8443"

use_ssl: True
Expand Down Expand Up @@ -75,6 +85,7 @@ oc_cmd: "{{ oc_client_install_path }}/oc"
oadm_cmd: "{{ oc_client_install_path }}/oadm"
kubectl_cmd: "{{ oc_client_install_path }}/kubectl"

oc_host_config_dir: /var/lib/origin/openshift.local.config

deploy_rds_demo_instance: true

Expand Down
12 changes: 11 additions & 1 deletion ansible/reset_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
- name: Setting fact of security group id
set_fact:
my_security_group_id: "{{ hostvars.localhost.my_ec2_facts.instances[0].groups[0].id }}"
vars_prompt:
- name: dockerhub_user_name
prompt: "Enter your dockerhub username: "
private: no
- name: dockerhub_user_password
prompt: "Enter your dockerhub password: "
private: yes
- name: dockerhub_org_name
prompt: "Enter the dockerhub organization you'd like to pull images from: "
private: no
roles:
- { role: ssl_setup, when: use_ssl == True }
- { role: openshift_setup, reset_cluster: True }
Expand All @@ -35,7 +45,7 @@
SSH Key Name: {{ ssh_key_name }}
Region: {{ aws_region }}
Next steps:
1) Visit https://apiserver-service-catalog.{{ openshift_hostname }}
1) Visit https://apiserver-service-catalog.{{ openshift_routing_suffix }}
2) Accept the certificate
3) Visit https://{{ openshift_hostname }}:8443 for the console
4) Provision a RDS APB into awsdemo project
Expand Down
2 changes: 1 addition & 1 deletion ansible/reset_local_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
msg: |
Hostname: {{ openshift_hostname }}
Next steps:
1) Visit https://apiserver-service-catalog.{{ openshift_hostname }}
1) Visit https://apiserver-service-catalog.{{ openshift_routing_suffix }}
2) Accept the certificate
3) Visit https://{{ openshift_hostname }}:8443 for the console
OR
Expand Down
31 changes: 31 additions & 0 deletions ansible/reset_mac_environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- hosts: localhost
gather_facts: True
vars_prompt:
- name: dockerhub_user_name
prompt: "Enter your dockerhub username: "
private: no
- name: dockerhub_user_password
prompt: "Enter your dockerhub password: "
private: yes
- name: dockerhub_org_name
prompt: "Enter the dockerhub organization you'd like to pull images from: "
private: no
roles:
- { role: openshift_setup, reset_cluster: True }
- service_catalog_setup
- ansible_service_broker_setup
- local_demo_prep
- env_hacks
post_tasks:
- set_fact:
msg: |
Hostname: {{ openshift_hostname }}
Next steps:
1) Visit https://apiserver-service-catalog.{{ openshift_routing_suffix }}
2) Accept the certificate
3) Visit https://{{ openshift_hostname }}:8443 for the console
OR
For CLI access:
oc login --insecure-skip-tls-verify {{ openshift_hostname }}:8443 -u {{ cluster_user }} -p {{ cluster_user_password }}
- debug:
msg: "{{ msg.split('\n') }}"
2 changes: 2 additions & 0 deletions ansible/roles/ansible_service_broker_setup/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
asb_src_dir: /tmp/ansible-service-broker
dockerhub_user_name: changeme
dockerhub_user_password: changeme
3 changes: 1 addition & 2 deletions ansible/roles/ansible_service_broker_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
pip:
requirements: "{{ asb_src_dir }}/scripts/asbcli/requirements.txt"
when: git_clone_asb.changed
become: 'true'
become: true

- name: Docker pull ansibleplaybookbundle/ansible-service-broker-apb:latest
docker_image:
Expand Down Expand Up @@ -75,7 +75,6 @@
src: ansible_service_broker.yaml.j2
dest: /tmp/ansible_service_broker.yaml
owner: "{{ ansible_env.USER }}"
group: "{{ ansible_env.USER }}"
mode: 0644
register: ansible_service_broker_template

Expand Down
111 changes: 41 additions & 70 deletions ansible/roles/openshift_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
shell: "{{ oc_cmd }} cluster down"
when: reset_cluster

- name: Install docker-py through pip as it's a requirement of ansible docker module
- name: Install docker through pip as it's a requirement of ansible docker module
pip:
name: docker-py
version: 1.10.6
name: docker
version: 2.3.0
become: 'true'

- name: Removing certain docker images if they exist so we are sure we are pulling latest
Expand All @@ -119,21 +119,21 @@
- "{{ docker_images_group1 }}"
- "{{ docker_images_group2 }}"

- name: Remove /var/lib/origin/openshift.local.config/master/master-config.yaml when resetting cluster
- name: Remove {{ oc_host_config_dir }}/master/master-config.yaml when resetting cluster
file:
path: /var/lib/origin/openshift.local.config/master/master-config.yaml
path: "{{ oc_host_config_dir }}/master/master-config.yaml"
state: absent
become: true
when: reset_cluster

# When reset_cluster is True we do not want to have to wait for the extra oc cluster up/down if it's not required
# so we are checking to see if the master-config.yaml exists, if it's there we will skip the extra oc cluster up/down
- stat:
path: /var/lib/origin/openshift.local.config/master/master-config.yaml
path: "{{ oc_host_config_dir }}/master/master-config.yaml"
register: master_config_stat

- stat:
path: /var/lib/origin/openshift.local.config/console-fullchain.pem
path: "{{ oc_host_config_dir }}/console-fullchain.pem"
register: console_ssl_stat

- name: Set a fact to tell if SSL was previously configured and now disabled
Expand All @@ -154,8 +154,16 @@
oc_cluster_up_first_run: True
when: "not 'cluster was started' in oc_cluster_status.stdout"

- name: Create command line for oc cluster up execution
set_fact:
oc_cluster_up_cmd: "{{ oc_cmd }} cluster up --routing-suffix={{ openshift_routing_suffix }} --public-hostname={{ openshift_hostname }} --host-pv-dir={{ persistedvol_mount_point }} --version=latest --image=docker.io/ansibleplaybookbundle/origin --host-config-dir={{ oc_host_config_dir }}"

- debug:
msg: "Looking at oc cluster up command: '{{ oc_cluster_up_cmd }}'"

# Intent of this oc cluster up is generate the master-config.yaml so we can make edits to it
- name: Run oc cluster up
shell: "{{ oc_cmd }} cluster up --routing-suffix={{ openshift_hostname }} --public-hostname={{ openshift_hostname }} --host-pv-dir={{ persistedvol_mount_point }} --version=latest --image=docker.io/ansibleplaybookbundle/origin"
shell: "{{ oc_cluster_up_cmd }}"
when: (oc_cluster_up_first_run and not master_config_stat.stat.exists) or ssl_changed is defined

- debug:
Expand All @@ -171,17 +179,6 @@
when: not ec2_install

# Intent of this oc cluster up is generate the master-config.yaml so we can make edits to it
- set_fact:
base_oc_cluster_cmd_line: "--routing-suffix={{ openshift_hostname }} --public-hostname={{ openshift_hostname }} --host-pv-dir={{ persistedvol_mount_point }} --version=latest --image=docker.io/ansibleplaybookbundle/origin"

- set_fact:
oc_cluster_cmd_line: "{{ base_oc_cluster_cmd_line }} --create-machine"
when: ansible_os_family == "Darwin"

- set_fact:
oc_cluster_cmd_line: "{{ base_oc_cluster_cmd_line }}"
when: ansible_os_family == "RedHat"

- name: Run oc cluster down
shell: "{{ oc_cmd }} cluster down"
when: (oc_cluster_up_first_run and not master_config_stat.stat.exists) or ssl_changed is defined
Expand All @@ -190,7 +187,7 @@
copy:
remote_src: True
src: /tmp/console-fullchain.pem
dest: /var/lib/origin/openshift.local.config/console-fullchain.pem
dest: "{{ oc_host_config_dir }}/console-fullchain.pem"
owner: root
group: root
mode: 0644
Expand All @@ -200,7 +197,7 @@
copy:
remote_src: True
src: /tmp/console-privkey.pem
dest: /var/lib/origin/openshift.local.config/console-privkey.pem
dest: "{{ oc_host_config_dir }}/console-privkey.pem"
owner: root
group: root
mode: 0644
Expand All @@ -210,7 +207,7 @@
copy:
remote_src: True
src: /tmp/apiserver-fullchain.pem
dest: /var/lib/origin/openshift.local.config/apiserver-fullchain.pem
dest: "{{ oc_host_config_dir }}/apiserver-fullchain.pem"
owner: root
group: root
mode: 0644
Expand All @@ -220,7 +217,7 @@
copy:
remote_src: True
src: /tmp/apiserver-privkey.pem
dest: /var/lib/origin/openshift.local.config/apiserver-privkey.pem
dest: "{{ oc_host_config_dir }}/apiserver-privkey.pem"
owner: root
group: root
mode: 0644
Expand All @@ -229,115 +226,89 @@
- name: Add extension script to oc config to talk to svc catalog
template:
src: extension.j2
dest: /var/lib/origin/openshift.local.config/extension.js
owner: root
group: root
dest: "{{ oc_host_config_dir }}/extension.js"
mode: 0644
register: extension_script_result
become: 'true'

- name: Edit master-config to allow extension scripts
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
regexp: "extensionDevelopment:"
line: " extensionDevelopment: true"
become: 'true'

- name: Add extension script to assetConfig
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
insertafter: "extensionScripts: null"
line: " - /var/lib/origin/openshift.local.config/extension.js"
become: 'true'

- name: Edit master-config to add extension script
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
regexp: "extensionScripts: null"
line: " extensionScripts:"
become: 'true'

- name: Add SSL cert to namedCertificates
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
insertafter: "namedCertificates: null"
line: " - certFile: /var/lib/origin/openshift.local.config/console-fullchain.pem"
line: " - certFile: {{ oc_host_config_dir }}/console-fullchain.pem"
when: use_ssl == True
become: 'true'

- name: Add SSL cert to namedCertificates
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
insertafter: "certFile: /var/lib/origin/openshift.local.config/console-fullchain.pem"
line: " keyFile: /var/lib/origin/openshift.local.config/console-privkey.pem"
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
insertafter: "certFile: {{ oc_host_config_dir }}/console-fullchain.pem"
line: " keyFile: {{ oc_host_config_dir }}/console-privkey.pem"
when: use_ssl == True
become: 'true'

- name: Add SSL cert to namedCertificates
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
insertafter: "keyFile: /var/lib/origin/openshift.local.config/console-privkey.pem"
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
insertafter: "keyFile: {{ oc_host_config_dir }}/console-privkey.pem"
line: " names:"
when: use_ssl == True
become: 'true'

- name: Add SSL cert to namedCertificates
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
insertafter: "names:"
line: " - \"apiserver-service-catalog.{{ openshift_hostname }}\""
line: " - \"apiserver-service-catalog.{{ openshift_routing_suffix }}\""
when: use_ssl == True
become: 'true'

- name: Add SSL cert to namedCertificates
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
insertafter: "names:"
line: " - \"{{ openshift_hostname }}\""
when: use_ssl == True
become: 'true'

- name: Edit master-config to allow SSL cert
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
dest: "{{ oc_host_config_dir }}/master/master-config.yaml"
regexp: "namedCertificates: null"
line: " namedCertificates:"
when: use_ssl == True
become: 'true'

- name: Add extension script to oc config to talk to svc catalog
template:
src: extension.j2
dest: /var/lib/origin/openshift.local.config/extension.js
owner: root
group: root
mode: 0644
become: 'true'
register: extension_script_result

- name: Edit master-config to allow extension scripts
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
regexp: "extensionDevelopment:"
line: " extensionDevelopment: true"
become: 'true'

- name: Add extension script to assetConfig
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
insertafter: "extensionScripts: null"
line: " - /var/lib/origin/openshift.local.config/extension.js"
become: 'true'
- name: Update oc cluster up command to use --use-existing-config
set_fact:
oc_cluster_up_cmd: "{{ oc_cluster_up_cmd }} --use-existing-config"

- name: Edit master-config to add extension script
lineinfile:
dest: /var/lib/origin/openshift.local.config/master/master-config.yaml
regexp: "extensionScripts: null"
line: " extensionScripts:"
become: 'true'
- debug:
msg: "Looking at oc cluster up command: '{{ oc_cluster_up_cmd }}'"

- name: Run oc cluster up
shell: "{{ oc_cmd }} cluster up --routing-suffix={{ openshift_hostname }} --public-hostname={{ openshift_hostname }} --host-pv-dir={{ persistedvol_mount_point }} --version=latest --image=docker.io/ansibleplaybookbundle/origin --host-config-dir=/var/lib/origin/openshift.local.config --use-existing-config"
shell: "{{ oc_cluster_up_cmd }}"
when: oc_cluster_up_first_run
register: oc_cluster_up
#
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/openshift_setup/templates/extension.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
window.OPENSHIFT_CONFIG.additionalServers = [{
hostPort: "apiserver-service-catalog.{{ openshift_hostname }}",
hostPort: "apiserver-service-catalog.{{ openshift_routing_suffix }}",
prefix: "/apis"
}];
Loading

0 comments on commit dc144d4

Please sign in to comment.