Add support for installing OS app that don't match with the ansible app

And use it for the CentOS instance of Noggin.

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
This commit is contained in:
Aurélien Bompard 2020-11-30 14:06:09 +01:00
parent 29ceba9b18
commit 593d7fe7f0
No known key found for this signature in database
GPG key ID: 31584CFEB9BF64AD
5 changed files with 23 additions and 15 deletions

View file

@ -56,12 +56,14 @@
imagename: noggin
- role: openshift/object
app: noggin-centos
app: noggin
os_app: noggin-centos
template: buildconfig.yml
objectname: buildconfig.yml
- role: openshift/object
app: noggin-centos
app: noggin
os_app: noggin-centos
template: configmap.yml
objectname: configmap.yml
noggin_theme: centos
@ -70,7 +72,8 @@
app: noggin-centos
- role: openshift/object
app: noggin-centos
app: noggin
os_app: noggin-centos
template: service.yml
objectname: service.yml
@ -84,17 +87,20 @@
haproxy.router.openshift.io/timeout: 5m
- role: openshift/object
app: noggin-centos
app: noggin
os_app: noggin-centos
template: secrets.yml
objectname: secrets.yml
- role: openshift/object
app: noggin-centos
app: noggin
os_app: noggin-centos
template: secret-webhook.yml
objectname: secret-webhook.yml
- role: openshift/object
app: noggin-centos
app: noggin
os_app: noggin-centos
template: deploymentconfig.yml
objectname: deploymentconfig.yml

View file

@ -0,0 +1 @@
os_app: "{{app}}"

View file

@ -1,18 +1,18 @@
- name: Copy template {{template}} to temporary file ({{tmpfile.path}})
template: src={{roles_path}}/openshift-apps/{{app}}/templates/{{template}} dest=/etc/openshift_apps/{{app}}/{{objectname}}
template: src={{roles_path}}/openshift-apps/{{app}}/templates/{{template}} dest=/etc/openshift_apps/{{os_app}}/{{objectname}}
when: template is defined
register: object_template
- name: Copy template {{template_fullpath}} to temporary file ({{tmpfile.path}})
template: src={{template_fullpath}} dest=/etc/openshift_apps/{{app}}/{{objectname}}
template: src={{template_fullpath}} dest=/etc/openshift_apps/{{os_app}}/{{objectname}}
when: template_fullpath is defined and template is not defined
register: object_template_fullpath
- name: Copy file {{file}} to temporary file ({{tmpfile.path}})
copy: src={{roles_path}}/openshift-apps/{{app}}/files/{{file}} dest=/etc/openshift_apps/{{app}}/{{objectname}}
copy: src={{roles_path}}/openshift-apps/{{app}}/files/{{file}} dest=/etc/openshift_apps/{{os_app}}/{{objectname}}
when: file is defined and template is not defined and template_fullpath is not defined
register: object_file
- name: Call `oc apply` on the copied file
shell: oc -n {{app}} apply -f /etc/openshift_apps/{{app}}/{{objectname}}
shell: oc -n {{os_app}} apply -f /etc/openshift_apps/{{os_app}}/{{objectname}}
when: object_template.changed or object_template_fullpath.changed or object_file.changed

View file

@ -0,0 +1 @@
os_app: "{{app}}"

View file

@ -1,26 +1,26 @@
- name: Copy template {{template}}
template: src={{roles_path}}/openshift-apps/{{app}}/templates/{{template}} dest=/etc/openshift_apps/{{app}}/{{key}}
template: src={{roles_path}}/openshift-apps/{{app}}/templates/{{template}} dest=/etc/openshift_apps/{{os_app}}/{{key}}
when: template is defined
register: secret_template
- name: Copy file {{file}}
copy: src={{roles_path}}/openshift-apps/{{app}}/files/{{file}} dest=/etc/openshift_apps/{{app}}/{{key}}
copy: src={{roles_path}}/openshift-apps/{{app}}/files/{{file}} dest=/etc/openshift_apps/{{os_app}}/{{key}}
when: file is defined
register: secret_file
- name: Copy private file {{privatefile}}
copy: src={{private}}/files/{{privatefile}} dest=/etc/openshift_apps/{{app}}/{{key}}
copy: src={{private}}/files/{{privatefile}} dest=/etc/openshift_apps/{{os_app}}/{{key}}
when: privatefile is defined
register: secret_privatefile
- name: Delete existing secrets
shell: oc -n {{app}} delete secret/{{secret_name}}
shell: oc -n {{os_app}} delete secret/{{secret_name}}
register: delete_out
changed_when: "'NotFound' in delete_out.stderr"
failed_when: "('NotFound' not in delete_out.stderr) and (delete_out.rc != 0)"
when: secret_template.changed or secret_file.changed or secret_privatefile.changed
- name: Call `oc secrets new` on the copied file
shell: oc -n {{app}} secrets new {{secret_name}} {{key}}=/etc/openshift_apps/{{app}}/{{key}}
shell: oc -n {{os_app}} secrets new {{secret_name}} {{key}}=/etc/openshift_apps/{{os_app}}/{{key}}
register: create_out
when: secret_template.changed or secret_file.changed or secret_privatefile.changed