Page MenuHomeDevCentral

Test salt-wrapper Salt deployment

Authored By
dereckson
Oct 4 2017, 15:53
Size
13 KB
Referenced Files
None
Subscribers
None

Test salt-wrapper Salt deployment

$ salt-call --local state.apply roles/saltmaster/salt-wrapper
local:
----------
ID: /usr/local/bin/salt-wrapper
Function: file.managed
Result: True
Comment: File /usr/local/bin/salt-wrapper updated
Started: 15:11:34.790637
Duration: 176.86 ms
Changes:
----------
diff:
---
+++
@@ -12,7 +12,7 @@
# Helper functions
#
# :: contains
-# -------------------------------------------------------------
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# contains(string, substring) #
@@ -32,7 +32,7 @@
# -------------------------------------------------------------
# Wrapper code
-# -------------------------------------------------------------
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CONFIG_DIR=$(salt-get-config-dir)
CODE=$?
----------
ID: /usr/local/bin/salt-get-config-dir
Function: file.managed
Result: True
Comment: File /usr/local/bin/salt-get-config-dir updated
Started: 15:11:34.968041
Duration: 18.24 ms
Changes:
----------
diff:
---
+++
@@ -1,15 +1,54 @@
#!/usr/bin/env python3
+
+# -------------------------------------------------------------
+# salt-get-config-dir command
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: salt-wrapper
+# Licence: BSD-2-Clause
+# -------------------------------------------------------------
+
+
import json
import os
import sys
-with open('/usr/local/etc/salt-wrapper.conf') as config_file:
- config = json.load(config_file)
-cwd = os.getcwd()
+# -------------------------------------------------------------
+# Load configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+config_file_path = os.environ.get(
+ "SALT_WRAPPER_CONF",
+ "/usr/local/etc/salt-wrapper.conf"
+)
+
+if not os.path.isfile(config_file_path):
+ print(
+ "The configuration file {0} doesn't exist.".format(config_file_path),
+ file=sys.stderr
+ )
+ print(
+ "See https://docs.nasqueron.org/salt-wrapper/admin.html#configuration-file", # noqa
+ file=sys.stderr
+ )
+ sys.exit(2)
+
+try:
+ with open(config_file_path) as config_file:
+ config = json.load(config_file)
+except OSError as err:
+ print("Can't open configuration file: {0}".format(err))
+ sys.exit(4)
+
+
+# -------------------------------------------------------------
+# Find configuration directory
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
for root in config['roots']:
- if cwd.startswith(root['states']):
+ if os.getcwd().startswith(root['states']):
print(root['config'])
sys.exit(0)
----------
ID: /usr/local/etc/salt-wrapper.conf
Function: file.managed
Result: True
Comment: File /usr/local/etc/salt-wrapper.conf updated
Started: 15:11:34.986864
Duration: 18.183 ms
Changes:
----------
diff:
---
+++
@@ -1,4 +1,13 @@
{
+ "comments": [
+ "This file is managed by our rOPS SaltStack repository.",
+
+ "Changes to this file may cause incorrect behavior",
+ "and will be lost if the state is redeployed.",
+
+ "Source file: roles/saltmaster/salt-wrapper/files/salt-wrapper.conf"
+ ],
+
"roots": [
{
"config": "/usr/local/etc/salt-woodscloud",
Summary for local
------------
Succeeded: 3 (changed=3)
Failed: 0
------------
Total states run: 3
Total run time: 213.283 ms
$ unsetenv SALT_WRAPPER_CONF
$ salt-get-config-dir
/usr/local/etc/salt
$ salt-call --local state.apply roles/saltmaster/salt-wrapper
local:
----------
ID: /usr/local/bin/salt-wrapper
Function: file.managed
Result: True
Comment: File /usr/local/bin/salt-wrapper is in the correct state
Started: 15:12:05.476958
Duration: 101.247 ms
Changes:
----------
ID: /usr/local/bin/salt-get-config-dir
Function: file.managed
Result: True
Comment: File /usr/local/bin/salt-get-config-dir is in the correct state
Started: 15:12:05.578803
Duration: 10.65 ms
Changes:
----------
ID: /usr/local/etc/salt-wrapper.conf
Function: file.managed
Result: True
Comment: File /usr/local/etc/salt-wrapper.conf is in the correct state
Started: 15:12:05.590011
Duration: 10.431 ms
Changes:
Summary for local
------------
Succeeded: 3
Failed: 0
------------
Total states run: 3
Total run time: 122.328 ms
$ which salt-call
salt-call: aliased to salt-wrapper salt-call

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
123896
Default Alt Text
Test salt-wrapper Salt deployment (13 KB)

Event Timeline