-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openshift_hosted: Update tasks to use oc_ modules
- Loading branch information
Showing
7 changed files
with
159 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,68 @@ | ||
--- | ||
- name: Retrieve list of openshift nodes matching registry selector | ||
command: > | ||
{{ openshift.common.client_binary }} --api-version='v1' -o json | ||
get nodes -n default --config={{ openshift_hosted_kubeconfig }} | ||
--selector={{ openshift.hosted.registry.selector | default('') }} | ||
register: registry_nodes_json | ||
changed_when: false | ||
oc_obj: | ||
state: list | ||
kind: node | ||
selector: "{{ openshift.hosted.registry.selector | default('') }}" | ||
register: registry_nodes | ||
when: openshift.hosted.registry.replicas | default(none) is none | ||
|
||
- set_fact: | ||
l_node_count: "{{ (registry_nodes_json.stdout | default('{\"items\":[]}') | from_json)['items'] | length }}" | ||
- name: set_fact l_node_count to number of nodes matching registry selector | ||
set_fact: | ||
l_node_count: "{{ registry_nodes.results.results[0]['items'] | length }}" | ||
|
||
# Determine the default number of registry/router replicas to use if no count | ||
# has been specified. | ||
# If no registry nodes defined, the default should be 0. | ||
- set_fact: | ||
- name: set_fact l_default_replicas when l_node_count == 0 | ||
set_fact: | ||
l_default_replicas: 0 | ||
when: l_node_count | int == 0 | ||
|
||
# If registry nodes are defined and the registry storage kind is | ||
# defined, default should be the number of registry nodes, otherwise | ||
# just 1: | ||
- set_fact: | ||
- name: set_fact l_default_replicas when l_node_count > 0 | ||
set_fact: | ||
l_default_replicas: "{{ l_node_count if openshift.hosted.registry.storage.kind | default(none) is not none else 1 }}" | ||
when: l_node_count | int > 0 | ||
|
||
- set_fact: | ||
- name: set_fact replicas | ||
set_fact: | ||
replicas: "{{ openshift.hosted.registry.replicas | default(l_default_replicas) }}" | ||
|
||
- name: Create OpenShift registry | ||
command: > | ||
{{ openshift.common.client_binary }} adm registry --create | ||
--config={{ openshift_hosted_kubeconfig }} | ||
{% if replicas > 1 -%} | ||
--replicas={{ replicas }} | ||
{% endif -%} | ||
--namespace={{ openshift.hosted.registry.namespace | default('default') }} | ||
--service-account=registry | ||
{% if openshift.hosted.registry.selector | default(none) is not none -%} | ||
--selector='{{ openshift.hosted.registry.selector }}' | ||
{% endif -%} | ||
{% if not openshift.common.version_gte_3_2_or_1_2 | bool -%} | ||
--credentials={{ openshift_master_config_dir }}/openshift-registry.kubeconfig | ||
{% endif -%} | ||
{% if openshift.hosted.registry.registryurl | default(none) is not none -%} | ||
--images='{{ openshift.hosted.registry.registryurl }}' | ||
{% endif -%} | ||
register: openshift_hosted_registry_results | ||
changed_when: "'service exists' not in openshift_hosted_registry_results.stdout" | ||
failed_when: "openshift_hosted_registry_results.rc != 0 and 'service exists' not in openshift_hosted_registry_results.stdout and 'deployment_config' not in openshift_hosted_registry_results.stderr and 'service' not in openshift_hosted_registry_results.stderr" | ||
oc_adm_registry: | ||
state: present | ||
name: registry | ||
namespace: "{{ openshift.hosted.registry.namespace | default('default') }}" | ||
selector: "{{ openshift.hosted.registry.selector }}" | ||
replicas: "{{ replicas }}" | ||
service_account: registry | ||
images: "{{ openshift.hosted.registry.registryurl }}" | ||
when: replicas | int > 0 | ||
|
||
- include: secure.yml | ||
static: no | ||
when: replicas | int > 0 and not (openshift.docker.hosted_registry_insecure | default(false) | bool) | ||
when: | ||
- replicas | int > 0 | ||
- not (openshift.docker.hosted_registry_insecure | default(false) | bool) | ||
|
||
- include: storage/object_storage.yml | ||
static: no | ||
when: replicas | int > 0 and openshift.hosted.registry.storage.kind | default(none) == 'object' | ||
when: | ||
- replicas | int > 0 | ||
- openshift.hosted.registry.storage.kind | default(none) == 'object' | ||
|
||
- include: storage/persistent_volume.yml | ||
static: no | ||
when: replicas | int > 0 and openshift.hosted.registry.storage.kind | default(none) in ['nfs', 'openstack'] | ||
- name: Add persistent volume to dc/docker-registry | ||
oc_adm_registry: | ||
state: present | ||
name: docker-registry | ||
namespace: "{{ openshift.hosted.registry.namespace | default('default') }}" | ||
volume_mounts: | ||
- name: registry-storage | ||
type: persistentVolumeClaim | ||
claim_name: "{{ openshift.hosted.registry.storage.volume.name }}-claim" | ||
when: | ||
- replicas | int > 0 | ||
- openshift.hosted.registry.storage.kind | default(none) in ['nfs', 'openstack'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
roles/openshift_hosted/tasks/registry/storage/persistent_volume.yml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.