-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scripts): deploy helper scripts
Deploy arbitrary helper scripts to use them in configuration file
- Loading branch information
Showing
7 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ keepalived: | |
config: | ||
global_defs: | ||
smtp_server: localhost | ||
scripts_dir: /etc/keepalived | ||
scripts: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
|
||
include: | ||
- .package | ||
- .scripts | ||
- .config | ||
- .service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .manage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- set sls_package_install = tplroot ~ '.package.install' %} | ||
{%- from tplroot ~ "/map.jinja" import keepalived with context %} | ||
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} | ||
include: | ||
- {{ sls_package_install }} | ||
{#- Don't create scripts_dir if no scripts defined #} | ||
{%- if 'scripts' in keepalived and keepalived.scripts %} | ||
keepalived-scripts-manage-file-directory: | ||
file.directory: | ||
- name: {{ keepalived.scripts_dir }} | ||
- makedirs: true | ||
- require: | ||
- sls: {{ sls_package_install }} | ||
{%- endif %} | ||
{%- for script,data in keepalived.scripts|dictsort %} | ||
{%- set ensure = data.get('ensure', present) %} | ||
{%- if ensure == 'present' %} | ||
keepalived-scripts-manage-file-managed-{{ script }}: | ||
file.managed: | ||
- name: {{ data.get('dst_file', keepalived.scripts_dir ~ '/' ~ script) }} | ||
- user: {{ data.get('user', 'root') }} | ||
- group: {{ data.get('group', 'root') }} | ||
- mode: {{ data.get('mode', '755') }} | ||
- template: {{ data.get('template_engine', 'jinja') }} | ||
{%- if 'contents' in data %} | ||
- contents: | | ||
{{ data.contents|indent(width=8) }} | ||
{%- elif 'template_file' in data %} | ||
- source: {{ files_switch([data.template_file]) }} | ||
- context: | ||
data: {{ data.context|tojson }} | ||
{%- endif %} | ||
- require: | ||
- sls: {{ sls_package_install }} | ||
{%- elif ensure == 'absent' %} | ||
keepalived-scripts-manage-file-absent-{{ script }}: | ||
file.absent: | ||
- name: {{ data.get('dst_file', keepalived.scripts_dir ~ '/' ~ script) }} | ||
{%- endif %} | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters