-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from valiantlynx/working
Update main.yml
- Loading branch information
Showing
1 changed file
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
--- | ||
- name: Remove useless packages from the cache | ||
become: true | ||
become_user: root | ||
become_method: sudo | ||
tasks: | ||
- name: Remove useless packages from the cache | ||
apt: | ||
autoclean: yes | ||
- name: Set up the swap area | ||
command: mkswap /dev/nvme1n1 | ||
- name: Enable swap | ||
command: swapon /dev/nvme1n1 | ||
- name: Make this swap setting persist by adding following line in /etc/fstab | ||
command: echo "/dev/nvme1n1 none swap sw 0 0" >> /etc/fstab | ||
apt: | ||
autoclean: yes | ||
|
||
- name: Check if swap file already exists | ||
become: true | ||
ansible.builtin.stat: | ||
path: /swapfile | ||
register: swapfile | ||
|
||
- name: Create a 1GB swap file | ||
become: true | ||
command: fallocate -l 1G /swapfile | ||
when: not swapfile.stat.exists | ||
|
||
- name: Secure swap file by setting up correct permissions | ||
become: true | ||
command: chmod 600 /swapfile | ||
when: not swapfile.stat.exists | ||
|
||
- name: Set up the swap area | ||
become: true | ||
command: mkswap /swapfile | ||
when: not swapfile.stat.exists | ||
|
||
- name: Enable swap | ||
become: true | ||
command: swapon /swapfile | ||
when: not swapfile.stat.exists | ||
|
||
- name: Make this swap setting persist by adding following line in /etc/fstab | ||
become: true | ||
lineinfile: | ||
path: /etc/fstab | ||
line: '/swapfile swap swap defaults 0 0' | ||
create: yes | ||
state: present | ||
when: not swapfile.stat.exists |