Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: require swap to run before datadoge #464

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pillar/prod/swapfile.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
swapfile:
size: 1024
path: /swapfile
swap_file:
swap_size: 1024
swap_path: /swapfile
22 changes: 11 additions & 11 deletions salt/base/swap.sls
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{% set swapfile = salt["pillar.get"]("swapfile", {}) %}
{% set size = swapfile.get("size", "1024") %}
{% set path = swapfile.get("path") %}
{% set swap_file = salt["pillar.get"]("swap_file", {}) %}
{% set swap_size = swap_file.get("swap_size", "1024") %}
{% set swap_path = swap_file.get("swap_path") %}

{% if path %}
{{ path }}:
{% if swap_path %}
{{ swap_path }}:
cmd.run:
- name: |
swapon --show=NAME --noheadings | grep -q "^{{ path }}$" && swapoff {{ path }}
rm -f {{ path }}
fallocate -l {{ size }}M {{ path }}
chmod 0600 {{ path }}
mkswap {{ path }}
- unless: bash -c "[[ $(($(stat -c %s {{ path }}) / 1024**2)) = {{ size }} ]]"
swapon --show=NAME --noheadings | grep -q "^{{ swap_path }}$" && swapoff {{ swap_path }}
rm -f {{ swap_path }}
fallocate -l {{ swap_size }}M {{ swap_path }}
chmod 0600 {{ swap_path }}
mkswap {{ swap_path }}
- unless: bash -c "[[ $(($(stat -c %s {{ swap_path }}) / 1024**2)) = {{ swap_size }} ]]"

mount.swap:
- persist: true
Expand Down
1 change: 1 addition & 0 deletions salt/datadog/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ datadog-agent:
- installed
- require:
- pkgrepo: datadog_repo
- mount: {{ swap_path }}
JacobCoffee marked this conversation as resolved.
Show resolved Hide resolved
service:
- running
- enable: True
Expand Down
Loading