No description
This repository has been archived on 2024-12-21. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
2019-05-07 21:43:56 +02:00
_modules Added readme, fixed xd_tofs.files_switch, fixed xd_Config 2019-05-07 21:43:56 +02:00
_states Initial commit 2019-05-02 19:54:21 +02:00
_utils Added readme, fixed xd_tofs.files_switch, fixed xd_Config 2019-05-07 21:43:56 +02:00
xd_templates/bash Initial commit 2019-05-02 19:54:21 +02:00
.gitignore added gitignore 2019-05-05 07:15:06 +02:00
README.md Added readme, fixed xd_tofs.files_switch, fixed xd_Config 2019-05-07 21:43:56 +02:00
requirements.txt Initial commit 2019-05-02 19:54:21 +02:00

utils-formula

This formula adds functionality to other formula's

Content

  1. libTOFS
  2. Pillar config
  3. Templates 3.1. bash/installer

1. libTOFS

this is a replacement for tofs.jinja, shipped by more official formula's.

usage:

my-state:
  file.managed:
    - source: {{ salt.xd_tofs.files_switch(['my-file.conf.jinja', 'my-file.conf'], tpldir = tpldir) }}

This will expand to:

my-state:
  file.managed:
    - source:
      - salt://tpldir/files/{grain:id}/my-file.conf.jinja
      - salt://tpldir/files/{grain:id}/my-file.conf
      - salt://tpldir/files/{grain:os_family}/my-file.conf.jinja
      - salt://tpldir/files/{grain:os_family}/my-file.conf
      - salt://tpldir/files/default/my-file.conf.jinja
      - salt://tpldir/files/default/my-file.conf

these files will be pulled from tpldir/files

NOTE: tpldir is a variable that is populated by salt in your sls file.

2. Pillar config (_utils/xd_Config)

usage:

# file: _pillar/cups.py

from xd_Config import xd_Config, xd_Config_Property

__virtualname__ = 'cups'

def __virtual__():
    return __virtualname__

class _cupsConfig(xd_Config):

    # Supports computed properties
    # This property will be available as pillar.cups.my_computed_property
    @xd_Config_Property
    def my_computed_property(self, original):
        return "Hello, World"

    # This property will be available as pillar.cups.my['custom-path']
    @xd_Config_Property(path = ['my', 'custom-path'])
    def my_custom_property2(self, original):
        return "Other property"

def ext_pillar(minion_id, pillar, **config):
    return _cupsConfig.ext_pillar(
        minion_id,
        pillar,
        config,
        opts = __opts__,
        grains = __grains__,
        salt = __salt__
    )

The following must be enabled (and highstated if managed by salt) before using the pillar variables

# file: /etc/salt/master.conf (or /etc/salt/minion.conf if masterless)

ext_pillar:
  - cups:
      name: cups
      path: [ cups ]

Now you are set-up to use the pillar configuration

3. Templates

3.1. bash/installer

TODO