k8s_secrets.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Create namespace
  16. kubernetes.core.k8s:
  17. api_version: v1
  18. kind: Namespace
  19. name: "{{ namespace }}"
  20. state: present
  21. - name: Encrypt timescaledb username
  22. shell: |
  23. set -o pipefail
  24. echo -n "{{ timescaledb_user }}" | base64
  25. register: timescaledb_user_encrypted
  26. changed_when: false
  27. no_log: true
  28. - name: Encrypt timescaledb password
  29. shell: |
  30. set -o pipefail
  31. echo -n "{{ timescaledb_password }}" | base64
  32. register: timescaledb_password_encrypted
  33. changed_when: false
  34. no_log: true
  35. - name: Encrypt mysqldb username
  36. shell: |
  37. set -o pipefail
  38. echo -n "{{ mysqldb_user }}" | base64
  39. register: mysqldb_user_encrypted
  40. changed_when: false
  41. no_log: true
  42. - name: Encrypt mysqldb password
  43. shell: |
  44. set -o pipefail
  45. echo -n "{{ mysqldb_password }}" | base64
  46. register: mysqldb_password_encrypted
  47. changed_when: false
  48. no_log: true
  49. - name: Encrypt mysqldb password for root user
  50. shell: |
  51. set -o pipefail
  52. echo -n "{{ mysqldb_root_password }}" | base64
  53. register: mysqldb_root_password_encrypted
  54. changed_when: false
  55. no_log: true
  56. - name: Kubernetes secrets
  57. kubernetes.core.k8s:
  58. state: present
  59. definition:
  60. apiVersion: v1
  61. kind: Secret
  62. metadata:
  63. name: "{{ secrets_name }}"
  64. namespace: "{{ namespace }}"
  65. type: Opaque
  66. data:
  67. timescaledb_user: "{{ timescaledb_user_encrypted.stdout }}"
  68. timescaledb_password: "{{ timescaledb_password_encrypted.stdout }}"
  69. sqldb_user: "{{ mysqldb_user_encrypted.stdout }}"
  70. sqldb_password: "{{ mysqldb_password_encrypted.stdout }}"
  71. sqldb_root_password: "{{ mysqldb_root_password_encrypted.stdout }}"