Support policy.yaml file [Final]

- Ceilometer
- Gnocchi
- Rally

This will copy only yaml or json policy file if they exist.

Change-Id: I59f3376ab9fb6fb83577465a6c9096764b9f19c0
Implements: blueprint support-custom-policy-yaml
Co-authored-By: Duong Ha-Quang <duonghq@vn.fujitsu.com>
This commit is contained in:
Dai Dang Van 2018-01-08 17:48:30 +07:00
parent 39d9327d29
commit 3d9fd47e96
16 changed files with 130 additions and 86 deletions

View File

@ -6,7 +6,7 @@
config_json: "{{ ceilometer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_conf: "{{ ceilometer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_pipeline: "{{ ceilometer_pipelines.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ ceilometer_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ ceilometer_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_notification_container: "{{ check_ceilometer_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
panko_conf: "{{ panko_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
@ -21,7 +21,7 @@
- service.enabled | bool
- config_json.changed | bool
or ceilometer_conf.changed | bool
or policy_json.changed | bool
or policy_overwriting.changed | bool
or ceilometer_events.changed | bool
or ceilometer_pipeline.changed | bool
or ceilometer_notification_container.changed | bool
@ -34,7 +34,7 @@
config_json: "{{ ceilometer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_conf: "{{ ceilometer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_pipeline: "{{ ceilometer_pipelines.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ ceilometer_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ ceilometer_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_central_container: "{{ check_ceilometer_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
@ -49,7 +49,7 @@
- config_json.changed | bool
or ceilometer_conf.changed | bool
or ceilometer_pipeline.changed | bool
or policy_json.changed | bool
or policy_overwriting.changed | bool
or ceilometer_central_container.changed | bool
- name: Restart ceilometer-compute container
@ -59,7 +59,7 @@
config_json: "{{ ceilometer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_conf: "{{ ceilometer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_pipeline: "{{ ceilometer_pipelines.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ ceilometer_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ ceilometer_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
ceilometer_compute_container: "{{ check_ceilometer_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
@ -75,6 +75,6 @@
- config_json.changed | bool
or ceilometer_conf.changed | bool
or ceilometer_pipeline.changed | bool
or policy_json.changed | bool
or policy_overwriting.changed | bool
or vcenter_ca_file.changed | bool
or ceilometer_compute_container.changed | bool

View File

@ -9,6 +9,23 @@
- item.value.enabled | bool
with_dict: "{{ ceilometer_services }}"
- name: Check if policies shall be overwritten
local_action: stat path="{{ item }}"
run_once: True
register: ceilometer_policy
with_first_found:
- files: "{{ supported_policy_format_list }}"
paths:
- "{{ node_custom_config }}/ceilometer/"
skip: true
- name: Set ceilometer policy file
set_fact:
ceilometer_policy_file: "{{ ceilometer_policy.results.0.stat.path | basename }}"
ceilometer_policy_file_path: "{{ ceilometer_policy.results.0.stat.path }}"
when:
- ceilometer_policy.results
- name: Copying over config.json files for services
template:
src: "{{ item.key }}.json.j2"
@ -115,18 +132,13 @@
notify:
- Restart ceilometer-compute container
- name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/ceilometer/policy.json"
run_once: True
register: ceilometer_policy
- name: Copying over existing policy.json
- name: Copying over existing policy file
template:
src: "{{ node_custom_config }}/ceilometer/policy.json"
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
register: ceilometer_policy_jsons
src: "{{ ceilometer_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ ceilometer_policy_file }}"
register: policy_jsons
when:
- ceilometer_policy.stat.exists
- ceilometer_policy_file is defined
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ceilometer_services }}"

View File

@ -6,14 +6,13 @@
"dest": "/etc/ceilometer/ceilometer.conf",
"owner": "ceilometer",
"perm": "0600"
},
}{% if ceilometer_policy_file is defined %},
{
"source": "{{ container_config_directory }}/policy.json",
"dest": "/etc/ceilometer/policy.json",
"source": "{{ container_config_directory }}/{{ ceilometer_policy_file }}",
"dest": "/etc/ceilometer/{{ ceilometer_policy_file }}",
"owner": "ceilometer",
"perm": "0600",
"optional": true
},
"perm": "0600"
}{% endif %},
{
"source": "{{ container_config_directory }}/pipeline.yaml",
"dest": "/etc/ceilometer/pipeline.yaml",

View File

@ -6,14 +6,13 @@
"dest": "/etc/ceilometer/ceilometer.conf",
"owner": "ceilometer",
"perm": "0600"
},
}{% if ceilometer_policy_file is defined %},
{
"source": "{{ container_config_directory }}/policy.json",
"dest": "/etc/ceilometer/policy.json",
"source": "{{ container_config_directory }}/{{ ceilometer_policy_file }}",
"dest": "/etc/ceilometer/{{ ceilometer_policy_file }}",
"owner": "ceilometer",
"perm": "0600",
"optional": true
},
"perm": "0600"
}{% endif %},
{
"source": "{{ container_config_directory }}/pipeline.yaml",
"dest": "/etc/ceilometer/pipeline.yaml",

View File

@ -24,14 +24,13 @@
"dest": "/etc/ceilometer/pipeline.yaml",
"owner": "ceilometer",
"perm": "0600"
},
}{% if ceilometer_policy_file is defined %},
{
"source": "{{ container_config_directory }}/policy.json",
"dest": "/etc/ceilometer/policy.json",
"source": "{{ container_config_directory }}/{{ ceilometer_policy_file }}",
"dest": "/etc/ceilometer/{{ ceilometer_policy_file }}",
"owner": "ceilometer",
"perm": "0600",
"optional": true
},
"perm": "0600"
}{% endif %},
{
"source": "{{ container_config_directory }}/panko.conf",
"dest": "/etc/panko/panko.conf",

View File

@ -52,3 +52,8 @@ ca_file = /etc/ceilometer/vmware_ca
[oslo_messaging_notifications]
transport_url = {{ notify_transport_url }}
{% if ceilometer_policy_file is defined %}
[oslo_policy]
policy_file = {{ ceilometer_policy_file }}
{% endif %}

View File

@ -5,7 +5,7 @@
service: "{{ gnocchi_services[service_name] }}"
config_json: "{{ gnocchi_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
gnocchi_conf: "{{ gnocchi_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ gnocchi_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ gnocchi_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
gnocchi_api_container: "{{ check_gnocchi_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
@ -19,7 +19,7 @@
- service.enabled | bool
- config_json.changed | bool
or gnocchi_conf.changed | bool
or policy_json.changed | bool
or policy_overwriting.changed | bool
or gnocchi_wsgi_conf.changed | bool
or gnocchi_api_container.changed | bool
@ -29,7 +29,7 @@
service: "{{ gnocchi_services[service_name] }}"
config_json: "{{ gnocchi_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
gnocchi_conf: "{{ gnocchi_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ gnocchi_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ gnocchi_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
gnocchi_metricd_container: "{{ check_gnocchi_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
@ -43,7 +43,7 @@
- service.enabled | bool
- config_json.changed | bool
or gnocchi_conf.changed | bool
or policy_json.changed | bool
or policy_overwriting.changed | bool
or gnocchi_metricd_container.changed | bool
- name: Restart gnocchi-statsd container
@ -52,7 +52,7 @@
service: "{{ gnocchi_services[service_name] }}"
config_json: "{{ gnocchi_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
gnocchi_conf: "{{ gnocchi_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ gnocchi_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ gnocchi_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
gnocchi_statsd_container: "{{ check_gnocchi_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
@ -66,5 +66,5 @@
- service.enabled | bool
- config_json.changed | bool
or gnocchi_conf.changed | bool
or policy_json.changed | bool
or policy_overwriting.changed | bool
or gnocchi_statsd_container.changed | bool

View File

@ -9,6 +9,23 @@
- item.value.enabled | bool
with_dict: "{{ gnocchi_services }}"
- name: Check if policies shall be overwritten
local_action: stat path="{{ item }}"
run_once: True
register: gnocchi_policy
with_first_found:
- files: "{{ supported_policy_format_list }}"
paths:
- "{{ node_custom_config }}/gnocchi/"
skip: true
- name: Set gnocchi policy file
set_fact:
gnocchi_policy_file: "{{ gnocchi_policy.results.0.stat.path | basename }}"
gnocchi_policy_file_path: "{{ gnocchi_policy.results.0.stat.path }}"
when:
- gnocchi_policy.results
- name: Copying over config.json files for services
template:
src: "{{ item.key }}.json.j2"
@ -59,18 +76,13 @@
notify:
- Restart gnocchi-api container
- name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/gnocchi/policy.json"
run_once: True
register: gnocchi_policy
- name: Copying over existing policy.json
- name: Copying over existing policy file
template:
src: "{{ node_custom_config }}/gnocchi/policy.json"
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
register: gnocchi_policy_jsons
src: "{{ gnocchi_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ gnocchi_policy_file }}"
register: gnocchi_policy_overwriting
when:
- gnocchi_policy.stat.exists
- gnocchi_policy_file is defined
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ gnocchi_services }}"

View File

@ -14,14 +14,13 @@
"dest": "/etc/{{ gnocchi_dir }}/wsgi-gnocchi.conf",
"owner": "gnocchi",
"perm": "0600"
},
}{% if gnocchi_policy_file is defined %},
{
"source": "{{ container_config_directory }}/policy.json",
"dest": "/etc/gnocchi/policy.json",
"source": "{{ container_config_directory }}/{{ gnocchi_policy_file }}",
"dest": "/etc/gnocchi/{{ gnocchi_policy_file }}",
"owner": "gnocchi",
"perm": "0600",
"optional": true
}{% if gnocchi_backend_storage == 'ceph' %},
"perm": "0600"
}{% endif %}{% if gnocchi_backend_storage == 'ceph' %},
{
"source": "{{ container_config_directory }}/ceph.conf",
"dest": "/etc/ceph/ceph.conf",

View File

@ -6,14 +6,13 @@
"dest": "/etc/gnocchi/gnocchi.conf",
"owner": "gnocchi",
"perm": "0600"
},
}{% if gnocchi_policy_file is defined %},
{
"source": "{{ container_config_directory }}/policy.json",
"dest": "/etc/gnocchi/policy.json",
"source": "{{ container_config_directory }}/{{ gnocchi_policy_file }}",
"dest": "/etc/gnocchi/{{ gnocchi_policy_file }}",
"owner": "gnocchi",
"perm": "0600",
"optional": true
}{% if gnocchi_backend_storage == 'ceph' %},
"perm": "0600"
}{% endif %}{% if gnocchi_backend_storage == 'ceph' %},
{
"source": "{{ container_config_directory }}/ceph.conf",
"dest": "/etc/ceph/ceph.conf",

View File

@ -6,14 +6,13 @@
"dest": "/etc/gnocchi/gnocchi.conf",
"owner": "gnocchi",
"perm": "0600"
},
}{% if gnocchi_policy_file is defined %},
{
"source": "{{ container_config_directory }}/policy.json",
"dest": "/etc/gnocchi/policy.json",
"source": "{{ container_config_directory }}/{{ gnocchi_policy_file }}",
"dest": "/etc/gnocchi/{{ gnocchi_policy_file }}",
"owner": "gnocchi",
"perm": "0600",
"optional": true
}{% if gnocchi_backend_storage == 'ceph' %},
"perm": "0600"
}{% endif %}{% if gnocchi_backend_storage == 'ceph' %},
{
"source": "{{ container_config_directory }}/ceph.conf",
"dest": "/etc/ceph/ceph.conf",

View File

@ -49,6 +49,11 @@ memcache_security_strategy = ENCRYPT
memcache_secret_key = {{ memcache_secret_key }}
memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ memcached_port }}{% if not loop.last %},{% endif %}{% endfor %}
{% if gnocchi_policy_file is defined %}
[oslo_policy]
policy_file = {{ gnocchi_policy_file }}
{% endif %}
[storage]
{% if gnocchi_backend_storage == 'file' %}
driver = file

View File

@ -5,7 +5,7 @@
service: "{{ rally_services[service_name] }}"
config_json: "{{ rally_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
rally_conf: "{{ rally_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ rally_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ rally_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
rally_container: "{{ check_rally_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
@ -19,5 +19,5 @@
- service.enabled | bool
- config_json.changed | bool
or rally_conf.changed | bool
or policy_json.changed | bool
or policy_overwriting.changed | bool
or rally_container.changed | bool

View File

@ -9,6 +9,23 @@
- item.value.enabled | bool
with_dict: "{{ rally_services }}"
- name: Check if policies shall be overwritten
local_action: stat path="{{ item }}"
run_once: True
register: rally_policy
with_first_found:
- files: "{{ supported_policy_format_list }}"
paths:
- "{{ node_custom_config }}/rally/"
skip: true
- name: Set rally policy file
set_fact:
rally_policy_file: "{{ rally_policy.results.0.stat.path | basename }}"
rally_policy_file_path: "{{ rally_policy.results.0.stat.path }}"
when:
- rally_policy.results
- name: Copying over config.json files for services
template:
src: "{{ item.key }}.json.j2"
@ -37,18 +54,13 @@
notify:
- Restart rally container
- name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/rally/policy.json"
run_once: True
register: rally_policy
- name: Copying over existing policy.json
- name: Copying over existing policy file
template:
src: "{{ node_custom_config }}/rally/policy.json"
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
register: rally_policy_jsons
src: "{{ rally_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ rally_policy_file }}"
register: rally_policy_overwriting
when:
- rally_policy.stat.exists
- rally_policy_file is defined
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ rally_services }}"

View File

@ -7,3 +7,8 @@ log_dir = /var/log/kolla/rally/
[database]
connection = mysql+pymysql://{{ rally_database_user }}:{{ rally_database_password }}@{{ rally_database_address }}/{{ rally_database_name }}
max_retries = -1
{% if rally_policy_file is defined %}
[oslo_policy]
policy_file = {{ rally_policy_file }}
{% endif %}

View File

@ -6,14 +6,13 @@
"dest": "/etc/rally/rally.conf",
"owner": "rally",
"perm": "0600"
},
}{% if rally_policy_file is defined %},
{
"source": "{{ container_config_directory }}/policy.json",
"dest": "/etc/rally/policy.json",
"source": "{{ container_config_directory }}/{{ rally_policy_file }}",
"dest": "/etc/rally/{{ rally_policy_file }}",
"owner": "rally",
"perm": "0600",
"optional": true
}
"perm": "0600"
}{% endif %}
],
"permissions": [
{