Browse Source

Manage grains using support metadata

Change-Id: I25fb0eb0d4b922b8853eceb0c1c220a4040e1704
pull/92/head
Filip Pytloun 7 years ago
parent
commit
e70606d0d2
5 changed files with 17 additions and 41 deletions
  1. +0
    -10
      linux/files/sphinx.grain
  2. +0
    -3
      linux/map.jinja
  3. +13
    -1
      linux/meta/salt.yml
  4. +4
    -24
      linux/system/doc.sls
  5. +0
    -3
      linux/system/init.sls

+ 0
- 10
linux/files/sphinx.grain View File

{%- set service_grains = {'sphinx': {'doc': {}}} %}
{%- for service_name, service in pillar.items() %}
{%- if service.get('_support', {}).get('sphinx', {}).get('enabled', False) %}
{%- set grains_fragment_file = service_name+'/meta/sphinx.yml' %}
{%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
{%- set grains_yaml = load_grains_file()|load_yaml %}
{%- set _dummy = service_grains.sphinx.doc.update({ service_name: grains_yaml.doc }) %}
{%- endif %}
{%- endfor %}
{{ service_grains|yaml(False) }}

+ 0
- 3
linux/map.jinja View File

}, },
'selinux': 'permissive', 'selinux': 'permissive',
'ca_certs_dir': '/usr/local/share/ca-certificates', 'ca_certs_dir': '/usr/local/share/ca-certificates',
'doc_validity_pkgs': ['python-yaml'],
}, },
'Debian': { 'Debian': {
'pkgs': ['python-apt', 'apt-transport-https', 'libmnl0'], 'pkgs': ['python-apt', 'apt-transport-https', 'libmnl0'],
}, },
'selinux': 'permissive', 'selinux': 'permissive',
'ca_certs_dir': '/usr/local/share/ca-certificates', 'ca_certs_dir': '/usr/local/share/ca-certificates',
'doc_validity_pkgs': ['python-yaml'],
}, },
'RedHat': { 'RedHat': {
'pkgs': ['policycoreutils', 'policycoreutils-python', 'telnet', 'wget'], 'pkgs': ['policycoreutils', 'policycoreutils-python', 'telnet', 'wget'],
}, },
'selinux': 'permissive', 'selinux': 'permissive',
'ca_certs_dir': '/usr/local/share/ca-certificates', 'ca_certs_dir': '/usr/local/share/ca-certificates',
'doc_validity_pkgs': ['PyYAML'],
}, },
}, grain='os_family', merge=salt['pillar.get']('linux:system')) %} }, grain='os_family', merge=salt['pillar.get']('linux:system')) %}



+ 13
- 1
linux/meta/salt.yml View File

{%- from "linux/map.jinja" import system with context -%}
orchestrate: orchestrate:
system: system:
priority: 30 priority: 30
priority: 40 priority: 40
storage: storage:
priority: 50 priority: 50

grain:
sphinx:
{%- set service_grains = {'sphinx': {'doc': {}}} %}
{%- for service_name, service in pillar.items() %}
{%- if service.get('_support', {}).get('sphinx', {}).get('enabled', False) %}
{%- set grains_fragment_file = service_name+'/meta/sphinx.yml' %}
{%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
{%- set grains_yaml = load_grains_file()|load_yaml %}
{%- do service_grains.sphinx.doc.update({ service_name: grains_yaml.doc }) %}
{%- endif %}
{%- endfor %}
{{ service_grains|yaml(False)|indent(4) }}

+ 4
- 24
linux/system/doc.sls View File

{%- from "linux/map.jinja" import system with context %} {%- from "linux/map.jinja" import system with context %}
{%- if system.enabled %} {%- if system.enabled %}


linux_system_doc_grains_dir:
file.directory:
- name: /etc/salt/grains.d
- mode: 700
- makedirs: true
- user: root
# This state is obsolete, grains are now managed from salt.minion.grains so we
# will just include it


linux_system_doc_grain:
file.managed:
- name: /etc/salt/grains.d/sphinx
- source: salt://linux/files/sphinx.grain
- template: jinja
- mode: 600
- require:
- file: linux_system_doc_grains_dir

linux_system_doc_validity_check:
pkg.installed:
- pkgs: {{ system.doc_validity_pkgs }}
cmd.wait:
- name: python -c "import yaml; stream = file('/etc/salt/grains.d/sphinx', 'r'); yaml.load(stream); stream.close()"
- require:
- pkg: linux_system_doc_validity_check
- watch:
- file: linux_system_doc_grain
include:
- salt.minion.grains


{%- endif %} {%- endif %}

+ 0
- 3
linux/system/init.sls View File

{%- if system.console is defined %} {%- if system.console is defined %}
- linux.system.console - linux.system.console
{%- endif %} {%- endif %}
{%- if system.doc is defined %}
- linux.system.doc
{%- endif %}
{%- if system.limit|length > 0 %} {%- if system.limit|length > 0 %}
- linux.system.limit - linux.system.limit
{%- endif %} {%- endif %}

Loading…
Cancel
Save