Page MenuHomeDevCentral

D404.diff
No OneTemporary

D404.diff

diff --git a/pillar/core/hostnames.sls b/pillar/core/hostnames.sls
new file mode 100644
--- /dev/null
+++ b/pillar/core/hostnames.sls
@@ -0,0 +1,2 @@
+hostnames:
+ eglide: eglide.org
diff --git a/pillar/top.sls b/pillar/top.sls
--- a/pillar/top.sls
+++ b/pillar/top.sls
@@ -7,6 +7,8 @@
# -------------------------------------------------------------
base:
+ '*':
+ - core.hostnames
eglide:
- users.revokedusers
- users.shellusers
diff --git a/roles/core/hostname/init.sls b/roles/core/hostname/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/core/hostname/init.sls
@@ -0,0 +1,35 @@
+# -------------------------------------------------------------
+# Salt — Set machine hostname
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2016-06-15
+# Description: Set hostname
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Store hostname into a configuration file
+# -------------------------------------------------------------
+
+hostname:
+ file.managed:
+ - name: /etc/hostname
+ - contents: {{ pillar.get('hostnames')[grains['id']] }}
+
+# -------------------------------------------------------------
+# When the hostname is changed, what to run afterwards?
+# -------------------------------------------------------------
+
+after_hostname_change:
+ cmd.run:
+ - name: hostname `cat /etc/hostname`
+ - onchanges:
+ - file: /etc/hostname
+
+{% if grains['os'] == 'Debian' or grains['os'] == 'Ubuntu' %}
+after_hostname_change_debian:
+ cmd.run:
+ - name: invoke-rc.d hostname.sh start
+ - onchanges:
+ - file: /etc/hostname
+{% endif %}
diff --git a/top.sls b/top.sls
--- a/top.sls
+++ b/top.sls
@@ -9,6 +9,7 @@
base:
'*':
- roles/core/rc
+ - roles/core/hostname
- roles/core/network
'eglide':
- roles/shellserver/users

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 21, 10:37 (4 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2589224
Default Alt Text
D404.diff (2 KB)

Event Timeline