Skip to content

Commit

Permalink
Finished unforking mgmt deployment tasks and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
batKem authored and Dominique Quatravaux committed Feb 7, 2020
1 parent 6a9345c commit f451510
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 186 deletions.
6 changes: 0 additions & 6 deletions ansible/roles/wordpress-openshift-namespace/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,5 @@
- ci.jenkinsfile

- name: "Management container (ssh server, PHP CLI)"
when: not openshift_namespace == "wwp-int"
import_tasks: mgmt.yml
tags: mgmt

- name: wwp-int-mgmt-deployment
when: openshift_namespace == "wwp-int"
include_tasks:
file: wwp-int-mgmt.yml
109 changes: 66 additions & 43 deletions ansible/roles/wordpress-openshift-namespace/tasks/mgmt.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

- include_vars: mgmt-vars.yml
tags: always
- include_vars: ../../../vars/ssh-keys.yml # Required by mgmt-vars.yml
Expand All @@ -7,6 +9,7 @@
- include_vars: ../../../vars/persistent-ressources.yml
tags: always


- name: "PersistentVolumeClaim"
connection: local
openshift:
Expand Down Expand Up @@ -38,69 +41,89 @@
name: "{{ mgmt_secret_name }}"
namespace: "{{ openshift_namespace }}"
labels:
app: mgmt
app: "{{mgmt_app_name}}"
data:
{{ mgmt_secret_contents | to_yaml | indent(width=2) }}
- name: mgmt DeploymentConfig
- name: DeploymentConfigs
connection: local
openshift:
state: latest
content: |
apiVersion: v1
kind: DeploymentConfig
metadata:
name: mgmt
name: "{{mgmt_app_name}}"
namespace: "{{ openshift_namespace }}"
labels:
app: mgmt
app: "{{mgmt_app_name}}"
spec:
replicas: 1
selector:
app: mgmt
deploymentconfig: mgmt
app: "{{mgmt_app_name}}"
deploymentconfig: "{{mgmt_app_name}}"
template:
metadata:
labels:
app: mgmt
deploymentconfig: mgmt
spec:
app: "{{mgmt_app_name}}"
deploymentconfig: "{{mgmt_app_name}}"
spec:
containers:
- name: mgmt
imagePullPolicy: Always
ports:
- containerPort: 22
protocol: TCP
volumeMounts:
- name: "{{mgmt_app_name}}"
imagePullPolicy: Always
ports:
- containerPort: 22
protocol: TCP
{% if openshift_is_wp_int %}
env:
- name: DB_HOST
valueFrom:
secretKeyRef:
key: host
name: database-access
- name: DB_USER
valueFrom:
secretKeyRef:
key: username
name: database-access
- name: DB_PASS
valueFrom:
secretKeyRef:
key: password
name: database-access
{% endif %}
volumeMounts:
- name: srv
mountPath: /srv
- name: ssh
mountPath: /var/lib/secrets/ssh
{% if (openshift_is_production or openshift_is_wp_int) %}
- name: backups
mountPath: /backups
{% endif %}
serviceAccount: "{{ mgmt_service_account }}"
serviceAccountName: "{{ mgmt_service_account }}"
volumes:
- name: srv
mountPath: /srv
persistentVolumeClaim:
claimName: '{{openshift_pvc_name}}'
- name: ssh
mountPath: /var/lib/secrets/ssh
{% if openshift_is_production %}
secret:
secretName: "{{ mgmt_secret_name }}"
{% if (openshift_is_production or openshift_is_wp_int) %}
- name: backups
mountPath: /backups
{% endif %}
serviceAccount: {{ mgmt_service_account }}
serviceAccountName: {{ mgmt_service_account }}
volumes:
- name: srv
persistentVolumeClaim:
claimName: wordpress-0
- name: ssh
secret:
secretName: "{{ mgmt_secret_name }}"
{% if openshift_is_production %}
- name: backups
persistentVolumeClaim:
claimName: backups-0
persistentVolumeClaim:
claimName: "{{ openshift_backup_volume_name }}"
{% endif %}
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- mgmt
from:
kind: ImageStreamTag
name: "{{ mgmt_image_name }}:{{ openshift_registry_tag }}"
namespace: "{{ openshift_namespace }}"
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- "{{mgmt_app_name}}"
from:
kind: ImageStreamTag
name: "{{ mgmt_image_name }}:{{ openshift_registry_tag }}"
namespace: "{{ openshift_namespace }}"
136 changes: 0 additions & 136 deletions ansible/roles/wordpress-openshift-namespace/tasks/wwp-int-mgmt.yml

This file was deleted.

3 changes: 2 additions & 1 deletion ansible/roles/wordpress-openshift-namespace/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

openshift_is_production: "{{ openshift_namespace == 'wwp' }}"
openshift_is_wp_int: "{{ openshift_namespace == 'wwp-int' }}"
openshift_registry_tag: "{{ 'prod' if openshift_is_production else 'latest' }}"
openshift_registry_tag: "{{ 'prod' if openshift_is_production or openshift_is_wp_int else 'latest' }}"
openshift_backup_volume_name: "{{ 'backups-readonly' if openshift_is_wp_int else 'backup-0' }}"

# for imageStream authentification
#TODO: remove the need for authentification
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# See also ssh keys and more in
# ../../../hosts-{dev,prod}/group_vars/openshift-namespaces-*

mgmt_app_name: mgmt-test

mgmt_service_account: "{{ openshift_namespace }}"

mgmt_access_list:
Expand Down

0 comments on commit f451510

Please sign in to comment.