Move single ansible playbook to ansible directory

Make ansible playbook properly- use ansible-galaxy init commands.
This commit is contained in:
ducoterra
2022-01-31 13:44:46 -05:00
parent c3ee4cf837
commit 838dad0302
183 changed files with 3232 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
---
# Create swap
- name: Turn off swap
command: "swapoff --all"
become: yes
- name: Remove old swap file
file:
state: absent
path: "{{ swap_file_path }}"
become: yes
- name: Create swap file
command: truncate -s 0 "{{ swap_file_path }}"
creates="{{ swap_file_path }}"
become: yes
- name: Set swap compression
command: chattr +C "{{ swap_file_path }}"
become: yes
- name: Allocate swap space
command: fallocate -l "{{ swap_file_size_mb }}M" "{{ swap_file_path }}"
become: yes
- name: Change swap file permissions
file: path="{{ swap_file_path }}"
owner=root
group=root
mode=0600
become: yes
- name: "Check swap file type"
command: file {{ swap_file_path }}
register: swapfile
become: yes
- name: Make swap file
command: "mkswap {{ swap_file_path }}"
become: yes
- name: Write swap entry in fstab
mount: name=none
src={{ swap_file_path }}
fstype=swap
opts=sw
passno=0
dump=0
state=present
become: yes
- name: Mount swap
command: "swapon {{ swap_file_path }}"
become: yes
- name: Set swappiness
command: sysctl -w vm.swappiness=1
become: yes
- name: Make swappiness permanent
copy:
dest: "/etc/sysctl.d/99-swappiness.conf"
content: |
vm.swappiness=1
become: yes