50 lines
1.2 KiB
YAML
50 lines
1.2 KiB
YAML
---
|
|
- name: Get MySQL Service Info
|
|
kubernetes.core.k8s_info:
|
|
api_version: v1
|
|
kind: Service
|
|
name: mysql-service
|
|
namespace: default
|
|
register: service_info
|
|
|
|
- name: Extract ClusterIP from MySQL service
|
|
set_fact:
|
|
cluster_ip: "{{ service_info.resources[0].spec.clusterIP }}"
|
|
|
|
- name: Print ClusterIP
|
|
debug:
|
|
var: cluster_ip
|
|
- name: Create ConfigMap for laravelio
|
|
kubernetes.core.k8s:
|
|
name: laravelio-config
|
|
namespace: default
|
|
definition:
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: laravelio-config
|
|
data:
|
|
DB_HOST: "{{ cluster_ip }}"
|
|
DB_DATABASE: laravelio
|
|
DB_USERNAME: laraveliouser
|
|
DB_PASSWORD: "123456"
|
|
|
|
- name: Create laravelio Deployment
|
|
kubernetes.core.k8s:
|
|
namespace: default
|
|
state: present
|
|
src: roles/laravelio_deploy/templates/laravelio-deployment.yml
|
|
|
|
- name: Create laravelio Service
|
|
kubernetes.core.k8s:
|
|
namespace: default
|
|
state: present
|
|
src: roles/laravelio_deploy/templates/laravelio-service.yml
|
|
wait: yes
|
|
|
|
- name: Seed database
|
|
kubernetes.core.k8s_exec:
|
|
namespace: default
|
|
pod: laravelio
|
|
command: "php artisan db:seed"
|
|
when: seed_database is defined and seed_database == "true"
|