Browse Source

* Deploy services from common playbook

Jhon Honce 10 năm trước cách đây
mục cha
commit
3e533e199a

+ 8 - 0
playbooks/aws/openshift-cluster/launch.yml

@@ -25,6 +25,14 @@
       cluster: "{{ cluster_id }}"
       type: "{{ k8s_type }}"
 
+  - set_fact:
+      a_master: "{{ master_names[0] }}"
+  - add_host: name={{ a_master }} groups=service_master
+
 - include: update.yml
 
+- include: ../../common/openshift-cluster/create_services.yml
+  vars:
+     create_services__master: "{{ service_master }}"
+
 - include: list.yml

+ 14 - 0
playbooks/common/openshift-cluster/create_services.yml

@@ -0,0 +1,14 @@
+---
+- name: Debug Deploy OpenShift Services
+  hosts: localhost
+  gather_facts: no
+  tasks:
+  - debug: var=create_services__master
+
+- name: Deploy OpenShift Services
+  hosts: "{{ create_services__master }}"
+  connection: ssh
+  gather_facts: yes
+  roles:
+  - openshift_registry
+  - openshift_router

+ 8 - 7
playbooks/gce/openshift-cluster/launch.yml

@@ -24,20 +24,21 @@
       type: "{{ k8s_type }}"
 
   - set_fact:
-      oo_first_master: "{{ item }}"
-    with_items: master_names.split()
-  - debug: var=oo_first_master
+      a_master: "{{ master_names[0] }}"
+  - add_host: name={{ a_master }} groups=service_master
 
 - include: update.yml
 
 - name: Deploy OpenShift Services
-  hosts: oo_first_master
+  hosts: service_master
   connection: ssh
   gather_facts: yes
-  vars_files:
-  - vars.yml
   roles:
-  - openshift_docker_registry
+  - openshift_registry
   - openshift_router
 
+- include: ../../common/openshift-cluster/create_services.yml
+  vars:
+     create_services__master: "{{ service_master }}"
+
 - include: list.yml

+ 0 - 8
roles/openshift_docker_registry/tasks/main.yml

@@ -1,8 +0,0 @@
----
-- set_fact: _option_images="--images={{ openshift_registry_url|quote }}"
-  when: openshift_registry_url is defined
-
-- name: Deploy OpenShift Docker Registry
-  command: openshift admin registry --create --credentials="{{ansible_env['HOME']}}"/.config/openshift/config {{ _option_images|default() }}
-  register: _openshift_docker_registry__results
-  changed_when: "'service exists' not in _openshift_docker_registry__results.stdout"

roles/openshift_docker_registry/README.md → roles/openshift_registry/README.md


roles/openshift_docker_registry/handlers/main.yml → roles/openshift_registry/handlers/main.yml


roles/openshift_docker_registry/meta/main.yml → roles/openshift_registry/meta/main.yml


+ 8 - 0
roles/openshift_registry/tasks/main.yml

@@ -0,0 +1,8 @@
+---
+- set_fact: _option_images="--images={{ openshift_registry_url|quote }}"
+  when: openshift_registry_url is defined
+
+- name: Deploy OpenShift Registry
+  command: openshift admin registry --create --credentials=/var/lib/openshift/openshift.local.certificates/openshift-registry/.kubeconfig {{ _option_images|default() }}
+  register: _openshift_registry__results
+  changed_when: "'service exists' not in _openshift_registry__results.stdout"

roles/openshift_docker_registry/vars/main.yml → roles/openshift_registry/vars/main.yml


+ 1 - 1
roles/openshift_router/tasks/main.yml

@@ -3,6 +3,6 @@
   when: openshift_registry_url is defined
 
 - name: Deploy OpenShift Router
-  command: openshift ex router --create --credentials="{{ansible_env['HOME']}}"/.config/openshift/config {{ _option_images|default() }}
+  command: openshift ex router --create --credentials=/var/lib/openshift/openshift.local.certificates/openshift-router/.kubeconfig {{ _option_images|default() }}
   register: _openshift_router__results
   changed_when: "'service exists' not in _openshift_router__results.stdout"