|
- {%- from "salt/map.jinja" import minion with context -%}
- {%- from "linux/map.jinja" import system with context -%}
- {%- if minion.masters is defined -%}
- master:
- {%- for master in minion.masters %}
- - {{ master.host }}
- {%- endfor %}
- {%- if minion.get('master_type', 'default') == "failover" %}
- master_type: failover
- retry_dns: 0
- master_shuffle: True
- master_alive_interval: 60
- {%- endif %}
- {%- else %}
- master: {{ minion.master.host }}
- {%- endif %}
- id: {{ minion.id | default(system.name~"."~system.domain) }}
- {%- set opt_list=[
- 'acceptance_wait_time',
- 'acceptance_wait_time_max',
- 'auth_timeout',
- 'cachedir',
- 'grains_refresh_every',
- 'master_alive_interval',
- 'master_tries',
- 'max_event_size',
- 'random_reauth_delay',
- 'recon_default',
- 'recon_max'
- ] %}
- {%- for opt in opt_list %}
- {%- if minion.get(opt) %}
- {{ opt }}: {{ minion.get(opt) }}
- {%- endif %}
- {%- endfor %}
- {%- if minion.grains_cache is defined %}
- grains_cache: {{ minion.grains_cache }}
- {%- endif %}
- {%- if minion.recon_randomize is defined %}
- recon_randomize: {{ minion.recon_randomize }}
- {%- endif %}
- {%- if minion.rejected_retry is defined %}
- rejected_retry: {{ minion.rejected_retry }}
- {%- endif %}
-
- {%- set excluded_keys = ('master', 'system', 'public_keys', 'private_keys', 'known_hosts', '__reclass__', '_secret', '_param') %}
-
- grains:
- {%- if minion.get('manage_roles', True) %}
- roles:
- {%- for key, value in pillar.items() %}
- {%- if key not in excluded_keys %}
- {%- for subkey, subvalue in value.iteritems() %}
- {%- if subvalue.enabled is defined and subvalue.enabled %}
- - {{key}}.{{ subkey }}
- {%- endif %}
- {%- endfor %}
- {%- endif %}
- {%- endfor %}
- {%- endif %}
- services:
- {%- for key, value in pillar.items() %}
- {%- if key not in excluded_keys %}
- - {{key}}
- {%- endif %}
- {%- endfor %}
-
- grains_dirs:
- - /var/lib/salt/grains
-
- {%- if minion.mine is defined %}
-
- mine_functions:
- {%- for salt_module, salt_functions in minion.mine.module.iteritems() %}
- {{ salt_module }}: {{ salt_functions }}
- {%- endfor %}
- mine_interval: {{ minion.mine.get('interval', 30) }}
-
- {%- endif %}
-
- {%- if minion.log is defined %}
-
- {%- if minion.log.level is defined %}
- log_level: {{ minion.log.level }}
- {%- endif %}
-
- {%- if minion.log.file is defined %}
- log_file: {{ minion.log.file }}
- {%- endif %}
-
- {%- if minion.log.level_logfile is defined %}
- log_level_logfile: {{ minion.log.level_logfile }}
- {%- endif %}
-
- {%- endif %}
-
- state_output: {{ minion.get('log', {}).get('state_output', 'changes') }}
-
- {%- if minion.get('proxy', {}).get('host', "") != "" %}
- proxy_host: {{ minion.proxy.host }}
- proxy_port: {{ minion.proxy.port }}
- {%- endif %}
-
- {%- if minion.backend is defined %}
- backend: {{ minion.backend }}
- {%- endif %}
-
- {%- if minion.sentry is defined %}
- sentry_handler:
- {% for server in minion.sentry.servers %}
- servers:
- - {{ server }}
- {% endfor %}
- project: {{ pillar.salt.minion.sentry.project }}
- public_key: {{ pillar.salt.minion.sentry.public_key }}
- secret_key: {{ pillar.salt.minion.sentry.secret_key }}
- {% if pillar.salt.minion.sentry.log_level is defined %}
- log_level: {{ pillar.salt.minion.sentry.log_level }}
- {%- endif %}
- {%- endif %}
-
- {%- if pillar.get('galera', {}).get('master', {}).get('enabled', False) %}
-
- {%- from "galera/map.jinja" import master with context %}
- mysql.unix_socket: {{ master.socket }}
- mysql.user: '{{ pillar.galera.master.admin.user }}'
- mysql.pass: '{{ pillar.galera.master.admin.password }}'
- mysql.db: 'mysql'
- mysql.charset: 'utf8'
-
- {%- elif pillar.get('galera', {}).get('slave', {}).get('enabled', False) %}
-
- {%- from "galera/map.jinja" import slave with context %}
- mysql.unix_socket: {{ slave.socket }}
- mysql.user: '{{ pillar.galera.slave.admin.user }}'
- mysql.pass: '{{ pillar.galera.slave.admin.password }}'
- mysql.db: 'mysql'
- mysql.charset: 'utf8'
-
- {%- elif pillar.get('mysql', {}).get('server', {}).get('enabled', False) %}
-
- mysql.unix_socket: /var/run/mysqld/mysqld.sock
- {%- if pillar.mysql.server.admin is defined %}
- mysql.user: '{{ pillar.mysql.server.admin.user }}'
- mysql.pass: '{{ pillar.mysql.server.admin.password }}'
- {%- else %}
- mysql.user: 'root'
- mysql.pass: ''
- {%- endif %}
- mysql.db: 'mysql'
- mysql.charset: 'utf8'
-
- {%- endif %}
-
- {%- if pillar.get('mongodb', {}).server is defined %}
- mongodb.host: 'localhost'
- mongodb.port: {{ pillar.mongodb.server.bind.port }}
- {%- if pillar.mongodb.server.get('admin', {}).user is defined %}
- mongodb.user: '{{ pillar.mongodb.server.admin.user }}'
- {%- endif %}
- {%- if pillar.mongodb.server.get('admin', {}).password is defined %}
- mongodb.password: '{{ pillar.mongodb.server.admin.password }}'
- {%- endif %}
- {%- endif %}
-
- {%- if pillar.get('postgresql', {}).server is defined %}
- postgres.user: 'postgres'
- postgres.pass: ''
- postgres.db: 'template1'
- {%- endif %}
-
- {%- if pillar.get('gitlab', {}).client is defined %}
- gitlab.url: 'https://{{ pillar.gitlab.client.server.host }}/'
- gitlab.token: '{{ pillar.gitlab.client.server.token }}'
- {%- elif pillar.get('gitlab', {}).server is defined %}
- gitlab.url: 'https://{{ pillar.gitlab.server.server_name }}/'
- gitlab.token: '{{ pillar.gitlab.server.get('token', 'Set token in pillar') }}'
- {%- endif %}
-
- {%- if pillar.get('keystone', {}).get('server', {'enabled': False } ).enabled %}
- keystone.token: '{{ pillar.keystone.server.service_token }}'
- keystone.endpoint: 'http://{{ pillar.keystone.server.bind.private_address }}:{{ pillar.keystone.server.bind.private_port }}/v2.0'
- {%- endif %}
-
- {%- for handler in pillar.salt.minion.get("handlers", []) %}
-
- {%- if handler.engine == "udp"%}
- logstash_udp_handler:
- host: {{ handler.host }}
- port: {{ handler.port }}
- version: 1
- {%- endif %}
-
- {%- if handler.engine == "zmq"%}
- logstash_zmq_handler:
- address: tcp://{{ handler.host }}:{{ handler.port }}
- version: 1
- {%- endif %}
-
- {%- endfor %}
-
- {#-
- vim: syntax=jinja
- -#}
|