Page MenuHomeDevCentral

No OneTemporary

diff --git a/pillar/core/hostnames.sls b/pillar/core/hostnames.sls
new file mode 100644
index 0000000..9341a72
--- /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
index 22382b2..8563e37 100644
--- a/pillar/top.sls
+++ b/pillar/top.sls
@@ -1,13 +1,15 @@
# -------------------------------------------------------------
# Salt configuration for Nasqueron servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Created: 2016-04-10
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
base:
+ '*':
+ - core.hostnames
eglide:
- users.revokedusers
- users.shellusers
- users.shelladmins
diff --git a/roles/core/hostname/init.sls b/roles/core/hostname/init.sls
new file mode 100644
index 0000000..b751958
--- /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
index 8d900b0..90431c6 100644
--- a/top.sls
+++ b/top.sls
@@ -1,15 +1,16 @@
# -------------------------------------------------------------
# Salt configuration for Nasqueron servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Created: 2016-04-10
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
base:
'*':
- roles/core/rc
+ - roles/core/hostname
- roles/core/network
'eglide':
- roles/shellserver/users
- roles/shellserver/userland-software

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 1, 17:55 (1 d, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3121671
Default Alt Text
(2 KB)

Event Timeline