Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4020275
D2204.id5546.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D2204.id5546.diff
View Options
diff --git a/roles/core/init.sls b/roles/core/init.sls
--- a/roles/core/init.sls
+++ b/roles/core/init.sls
@@ -10,6 +10,7 @@
- .hostname
- .login
- .network
+ - .memory
- .motd
- .src
- .ports
diff --git a/roles/core/memory/init.sls b/roles/core/memory/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/core/memory/init.sls
@@ -0,0 +1,47 @@
+# -------------------------------------------------------------
+# Salt — Memory configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2020-02-12
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Provide SWAP
+#
+# Some servers can't be set up without any swap, especially
+# on Scaleway infrastructure. As a fallback, we can create
+# a swap file in such cases.
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% set swap_size = 8 * 1024 %}
+
+{% if grains['swap_total'] == 0 %}
+
+create_swap_file:
+ cmd.run:
+ # dd is here used, as fallocate compatibility with XFS and ext4
+ # hasn't been verified.
+ - name: dd if=/dev/zero of=/swapfile bs=1MiB count={{ swap_size }}
+ - creates: /swapfile
+
+secure_swap_file:
+ file.managed:
+ - name: /swapfile
+ - mode: 600
+ - replace: False
+
+enable_swap_file:
+ cmd.run:
+ - name: |
+ mkswap /swapfile
+ swapon /swapfile
+ touch /etc/.swap-enabled
+ - creates: /etc/.swap-enabled
+
+configure_fstab_for_swap_file:
+ file.append:
+ - name: /etc/fstab
+ - text: /swapfile none swap sw 0 0
+
+{% endif %}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 20, 03:13 (20 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2361518
Default Alt Text
D2204.id5546.diff (1 KB)
Attached To
Mode
D2204: Create swap file if no swap partition exist
Attached
Detach File
Event Timeline
Log In to Comment