kolla-ansible/ansible/roles/certificates/tasks/generate.yml
Duong Ha-Quang 26b2c2d9e9 Specify 'become' to necessary tasks (general roles)
Add config_owner_user and config_owner_group to group_vars/all,
which is user and group of Kolla configuration files in /etc/kolla.

Add become to post-deploy playbook.

Add become to only neccesary tasks in roles:
- certificate
- common
- destroy
- haproxy
- mariadb
- memcached
- rabbitmq

Change-Id: I2aba745a6e3928c52642f64551470fd08cbfd058
Partial-Implements: blueprint ansible-specific-task-become
2017-09-25 06:52:04 +00:00

48 lines
1.4 KiB
YAML

---
- name: Ensuring config directories exist
become: true
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
recurse: yes
with_items:
- "certificates/private"
- name: Creating SSL configuration file
become: true
template:
src: "{{ item }}.j2"
dest: "{{ node_config_directory }}/certificates/{{ item }}"
with_items:
- "openssl-kolla.cnf"
- name: Creating Key
become: true
command: creates="{{ item }}" openssl genrsa -out {{ item }}
with_items:
- "{{ node_config_directory }}/certificates/private/haproxy.key"
- name: Creating Server Certificate
become: true
command: creates="{{ item }}" openssl req -new -nodes -sha256 -x509 \
-subj "/C=US/ST=NC/L=RTP/O=kolla/CN={{ kolla_external_fqdn }}" \
-config {{ node_config_directory }}/certificates/openssl-kolla.cnf \
-days 3650 \
-extensions v3_req \
-key {{ node_config_directory }}/certificates/private/haproxy.key \
-out {{ item }}
with_items:
- "{{ node_config_directory }}/certificates/private/haproxy.crt"
- name: Creating CA Certificate File
become: true
copy:
src: "{{ node_config_directory }}/certificates/private/haproxy.crt"
dest: "{{ node_config_directory }}/certificates/haproxy-ca.crt"
- name: Creating Server PEM File
become: true
assemble:
src: "{{ node_config_directory }}/certificates/private"
dest: "{{ node_config_directory }}/certificates/haproxy.pem"