ansible-role-k8s-keystone/tasks/provision.yml

235 lines
6.3 KiB
YAML

- name: Create project
k8s_v1_namespace:
host: "{{coe_host}}"
context: "{{kube_context}}"
kubeconfig: "{{config_file}}"
name: openstack
state: present
debug: yes
register: create_project
- name: Upload config files
template:
src: "{{item}}"
dest: /tmp/{{item}}
backup: yes
mode: 0644
with_items:
- httpd.conf
- httpd-keystone-main.conf
- httpd-keystone-admin.conf
- keystone-schema.yaml
- include: hiera.yaml
- name: Generate config files
config_template:
src: base.conf.j2
dest: /tmp/keystone.conf
config_overrides: '{{keystone_config}}'
config_type: ini
- name: Read configs into memory
slurp:
src: "/tmp/httpd-keystone-main.conf"
register: "httpd_keystone_main_conf"
- name: Read configs into memory
slurp:
src: "/tmp/httpd-keystone-admin.conf"
register: "httpd_keystone_admin_conf"
- name: Read configs into memory
slurp:
src: "/tmp/httpd.conf"
register: "httpd_conf"
- name: Read configs into memory
slurp:
src: "/tmp/keystone.conf"
register: "keystone_conf"
- name: Create keystone configmaps
ignore_errors: yes
k8s_v1_config_map:
host: "{{coe_host}}"
context: "{{kube_context}}"
kubeconfig: "{{config_file}}"
name: keystone
namespace: openstack
state: present
debug: yes
labels:
service: keystone
data:
config.json: |
{
"command": "/usr/sbin/httpd -DFOREGROUND",
"config_files": [
{
"dest": "/etc/httpd/conf/httpd.conf",
"owner": "root",
"perm": "0644",
"source": "/var/lib/kolla/config_files/httpd.conf"
},
{
"dest": "/etc/keystone/keystone.conf",
"owner": "keystone",
"perm": "0644",
"source": "/var/lib/kolla/config_files/keystone.conf"
},
{
"dest": "/etc/httpd/conf.d/10-keystone-main.conf",
"owner": "root",
"perm": "0644",
"source": "/var/lib/kolla/config_files/httpd-keystone-main.conf"
},
{
"dest": "/etc/httpd/conf.d/10-keystone-admin.conf",
"owner": "root",
"perm": "0644",
"source": "/var/lib/kolla/config_files/httpd-keystone-admin.conf"
}
]
}
keystone.conf: |
{{keystone_conf['content'] | b64decode}}
httpd.conf: |
{{httpd_conf['content'] | b64decode}}
httpd-keystone-main.conf: |
{{httpd_keystone_main_conf['content'] | b64decode}}
httpd-keystone-admin.conf: |
{{httpd_keystone_admin_conf['content'] | b64decode}}
- name: Create keystone job
k8s_v1_job:
host: "{{coe_host}}"
context: "{{kube_context}}"
kubeconfig: "{{config_file}}"
name: keystone-db-sync
namespace: openstack
state: present
spec_template_metadata_annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "keystone-db-create",
"image": "tripleoupstream/centos-binary-mariadb",
"imagePullPolicy": "IfNotPresent",
"restartPolicy": "OnFailure",
"command": [
"mysql",
"-h",
"mariadb",
"-u",
"root",
"--password=weakpassword",
"-e",
"create database if not exists keystone;"
]
}
]'
restart_policy: OnFailure
containers:
- image: tripleoupstream/centos-binary-keystone
name: keystone-db-sync
env:
- name: KOLLA_CONFIG_STRATEGY
value: COPY_ALWAYS
- name: KOLLA_BOOTSTRAP
value: ''
volume_mounts:
- name: kolla-config
mountPath: /var/lib/kolla/config_files/
- name: keystone-fernet
mountPath: /etc/keystone/fernet-keys
volumes:
- name: kolla-config
config_map:
name: keystone
- name: keystone-fernet
state: present
- name: Create keystone fernet job
k8s_v1_job:
host: "{{coe_host}}"
context: "{{kube_context}}"
kubeconfig: "{{config_file}}"
name: keystone-fernet
namespace: openstack
state: present
restart_policy: OnFailure
containers:
- image: tripleoupstream/centos-binary-keystone-fernet
name: keystone-fernet-bootstrap
command: ["kolla_keystone_bootstrap", "keystone", "keystone"]
env:
- name: KOLLA_CONFIG_STRATEGY
value: COPY_ALWAYS
volume_mounts:
- name: kolla-config
mountPath: /var/lib/kolla/config_files/
- name: keystone-fernet
mountPath: /etc/keystone/fernet-keys
volumes:
- name: kolla-config
config_map:
name: keystone
- name: keystone-fernet
state: present
- name: Create keystone service
k8s_v1_service:
host: "{{coe_host}}"
context: "{{kube_context}}"
kubeconfig: "{{config_file}}"
name: keystone
namespace: openstack
state: present
ports:
- port: 5000
name: keystone-api-public
- port: 35357
name: keystone-api-admin
selector:
app: keystone-api
register: create_service
- name: Create keystone deployment
k8s_v1beta1_deployment:
host: "{{coe_host}}"
context: "{{kube_context}}"
kubeconfig: "{{config_file}}"
name: keystone-api
namespace: openstack
replicas: 1
spec_revision_history_limit: 3
spec_template_metadata_labels:
app: keystone-api
containers:
- name: keystone-api
image: docker.io/kolla/centos-binary-keystone:3.0.3
imagePullPolicy: IfNotPresent
env:
- name: KOLLA_CONFIG_STRATEGY
value: COPY_ALWAYS
- name: KOLLA_KUBERNETES
value: ""
ports:
- name: api-public
containerPort: 5000
- name: api-admin
containerPort: 35357
volume_mounts:
- name: kolla-config
mountPath: /var/lib/kolla/config_files/
- name: keystone-fernet
mountPath: /etc/keystone/fernet-keys
volumes:
- name: kolla-config
config_map:
name: keystone
- name: keystone-fernet
state: present
register: create_service