Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 11 additions & 3 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,9 +85,7 @@ oc_cmd: "{{ oc_client_install_path }}/oc"
oadm_cmd: "{{ oc_client_install_path }}/oadm"
kubectl_cmd: "{{ oc_client_install_path }}/kubectl"


dockerhub_user_name: "foo"
dockerhub_user_password: "foo"
oc_host_config_dir: /var/lib/origin/openshift.local.config

deploy_rds_demo_instance: true

Expand Down
2 changes: 1 addition & 1 deletion ansible/reset_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 @@ -12,7 +12,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
22 changes: 22 additions & 0 deletions ansible/reset_mac_environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- hosts: localhost
gather_facts: True
tasks:
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
11 changes: 8 additions & 3 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:summit
docker_image:
Expand All @@ -22,7 +22,13 @@
register: oc_get_projects_asb

- name: Use asbcli up to install Ansible Service Broker
shell: "./asbcli up {{ openshift_url }} --cluster-user={{ cluster_user }} --cluster-pass={{ cluster_user_password }} --dockerhub-user={{ dockerhub_user_name }} --dockerhub-pass={{ dockerhub_user_password }}"
shell: >
./asbcli up {{ openshift_url }}
--cluster-user={{ cluster_user }}
--cluster-pass={{ cluster_user_password }}
--dockerhub-user={{ dockerhub_user_name }}
--dockerhub-pass={{ dockerhub_user_password }}

args:
chdir: "{{ asb_src_dir }}/scripts/asbcli"
retries: 2
Expand Down Expand Up @@ -69,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
105 changes: 38 additions & 67 deletions ansible/roles/openshift_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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=summit --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=summit --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=summit --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=summit --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