blob: 796ec1e020c904ce2de1e4a15f27d259ae43dc16 [file] [log] [blame]
{%- from "designate/map.jinja" import server with context %}
{%- if server.enabled %}
include:
- designate.db.offline_sync
- designate._ssl.mysql
- designate._ssl.rabbitmq
{%- if server.backend is defined %}
{%- if server.backend.bind9 is defined %}
designate_bind_packages:
pkg.installed:
- names:
- bind9utils
{%- if server.backend.bind9.rndc_key is defined %}
/etc/designate/rndc.key:
file.managed:
- source: salt://designate/files/rndc.key
- template: jinja
- mode: 0640
- group: designate
- require:
- pkg: designate_server_packages
{%- endif %}
{%- endif %}
{%- endif %}
{%- for service_name in server.services %}
{{ service_name }}_default:
file.managed:
- name: /etc/default/{{ service_name }}
- source: salt://designate/files/default
- template: jinja
- require:
- pkg: designate_server_packages
- defaults:
service_name: {{ service_name }}
values: {{ server }}
- watch_in:
- service: designate_server_services
{%- endfor %}
{% if server.logging.log_appender %}
{%- if server.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
designate_fluentd_server_logger_package:
pkg.installed:
- name: python-fluent-logger
{%- endif %}
designate_general_logging_conf:
file.managed:
- name: /etc/designate/logging.conf
- source: salt://oslo_templates/files/logging/_logging.conf
- template: jinja
- mode: 0640
- user: root
- group: designate
- defaults:
service_name: designate
_data: {{ server.logging }}
- require_in:
- sls: designate.db.offline_sync
- require:
- pkg: designate_server_packages
{%- if server.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
- pkg: designate_fluentd_server_logger_package
{%- endif %}
- watch_in:
- service: designate_server_services
/var/log/designate/designate.log:
file.managed:
- user: designate
- group: designate
- watch_in:
- service: designate_server_services
{% for service_name in server.services %}
{{ service_name }}_logging_conf:
file.managed:
- name: /etc/designate/logging/logging-{{ service_name }}.conf
- source: salt://oslo_templates/files/logging/_logging.conf
- template: jinja
- makedirs: True
- mode: 0640
- user: root
- group: designate
- defaults:
service_name: {{ service_name }}
_data: {{ server.logging }}
- require:
- pkg: designate_server_packages
{%- if server.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
- pkg: designate_fluentd_server_logger_package
{%- endif %}
- watch_in:
- service: designate_server_services
{% endfor %}
{% endif %}
designate_server_packages:
pkg.installed:
- names: {{ server.pkgs }}
- require_in:
- sls: designate.db.offline_sync
- sls: designate._ssl.mysql
- sls: designate._ssl.rabbitmq
/etc/designate/designate.conf:
file.managed:
- source: salt://designate/files/{{ server.version }}/designate.conf.{{ grains.os_family }}
- template: jinja
- mode: 0640
- group: designate
- require:
- pkg: designate_server_packages
- sls: designate._ssl.mysql
- sls: designate._ssl.rabbitmq
- require_in:
- sls: designate.db.offline_sync
/etc/designate/api-paste.ini:
file.managed:
- source: salt://designate/files/{{ server.version }}/api-paste.ini
- template: jinja
- mode: 0640
- group: designate
- require:
- pkg: designate_server_packages
- sls: designate._ssl.mysql
- sls: designate._ssl.rabbitmq
- require_in:
- sls: designate.db.offline_sync
{%- if server.get('concurrency', {}).lock_path is defined %}
designate_lock_path_{{ server.concurrency.lock_path }}:
file.directory:
- name: {{ server.concurrency.lock_path }}
- user: designate
- group: designate
- mode: 750
- makedirs: True
- require:
- pkg: designate_server_packages
- require_in:
- service: designate_server_services
{%- endif %}
/etc/designate/{{ server.get('oslo_policy', {}).get('policy_file', 'policy.json') }}:
file.managed:
- source: salt://designate/files/{{ server.version }}/policy.json
- user: designate
- group: designate
{%- for name, rule in server.get('policy', {}).iteritems() %}
{%- if rule != None %}
designate_keystone_rule_{{ name }}_present:
keystone_policy.rule_present:
- path: /etc/designate/{{ server.get('oslo_policy', {}).get('policy_file', 'policy.json') }}
- name: {{ name }}
- rule: {{ rule }}
- require:
- pkg: designate_server_packages
- file: /etc/designate/{{ server.get('oslo_policy', {}).get('policy_file', 'policy.json') }}
{%- else %}
designate_keystone_rule_{{ name }}_absent:
keystone_policy.rule_absent:
- path: /etc/designate/{{ server.get('oslo_policy', {}).get('policy_file', 'policy.json') }}
- name: {{ name }}
- require:
- pkg: designate_server_packages
- file: /etc/designate/{{ server.get('oslo_policy', {}).get('policy_file', 'policy.json') }}
{%- endif %}
{%- endfor %}
{%- include "designate/server/export_policy_grains.sls" %}
designate_pool_sync:
cmd.run:
- name: designate-manage pool-manager-cache sync
- runas: designate
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- file: /etc/designate/designate.conf
designate_server_services:
service.running:
- enable: true
- names: {{ server.services }}
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
- require:
- sls: designate.db.offline_sync
- cmd: designate_pool_sync
- sls: designate._ssl.mysql
- sls: designate._ssl.rabbitmq
- watch:
- file: /etc/designate/designate.conf
{%- if server.version not in ['liberty', 'juno', 'kilo'] and server.pools is defined %}
# Since Mitaka it is recommended to use pools.yaml for pools configuration
/etc/designate/pools.yaml:
file.managed:
- source: salt://designate/files/{{ server.version }}/pools.yaml
- template: jinja
- mode: 0640
- group: designate
- require:
- pkg: designate_server_packages
{%- if not grains.get('noservices', False) %}
designate_pool_update:
cmd.run:
- name: "attempts=3; for i in $(seq 1 $attempts); do if designate-manage pool update; then exit 0; else if [[ $i -ge $attempts ]]; then exit 1; else sleep 10; fi; fi; done"
- runas: designate
- shell: /bin/bash
- require:
- service: designate_server_services
- onchanges:
- file: /etc/designate/pools.yaml
{%- endif %}
{%- endif %}
{%- endif %}