Skip to content

Instantly share code, notes, and snippets.

@mjinks
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjinks/714b10c3073f1eb6d720 to your computer and use it in GitHub Desktop.
Save mjinks/714b10c3073f1eb6d720 to your computer and use it in GitHub Desktop.
local:
----------
ID: motd-base-source
Function: file.managed
Name: /etc/motd
Result: None
Comment: The file /etc/motd is set to be changed
Started: 15:09:16.698367
Duration: 26.98 ms
Changes:
----------
diff:
---
+++
@@ -1,7 +1,16 @@
-Welcome to saltlab02!
+*********************************************************************
+ Welcome to saltlab02
-This is a template getting foo from the pillar, currently with no
-conditional: bar
+*** TAKE NOTE: This is a Salt minion. Changes made here might not ***
+*** stick the next time Salt runs! If in doubt, check with the ***
+*** systems team: <syseng@peerlessnetwork.com> ***
-Here we try to source the OS name from grains; OS is Debian
+
+
+
+
+Last updated: DATE
+*********************************************************************
+
+
----------
ID: motd-date
Function: file.replace
Name: /etc/motd
Result: True
Comment: No changes needed to be made
Started: 15:09:16.728809
Duration: 2.343 ms
Changes:
Summary
------------
Succeeded: 2 (unchanged=1, changed=1)
Failed: 0
------------
Total states run: 2
{% set mydate = salt['cmd.run_stdout']('date') %}
motd-base-source:
file.managed:
- name: /etc/motd
- template: jinja
- source:
- salt://motd/templates/motd.jinja
- salt://motd/files/motd.fallback
motd-date:
file.replace:
- name: /etc/motd
- pattern: DATE
- repl: {{ mydate }}
- show_changes: True
*********************************************************************
Welcome to {{ grains['fqdn'] }}
*** TAKE NOTE: This is a Salt minion. Changes made here might not ***
*** stick the next time Salt runs! If in doubt, check with the ***
*** systems team: <syseng@peerlessnetwork.com> ***
{# mjinks: current goal here is to insert a statement, "this host last #}
{# updated `date`. #}
{# salt.states.file.blockreplace and salt.modules.cmdmod are the #}
{# syllabus. #}
Last updated: DATE
*********************************************************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment