semaphore-playbooks/debian12-basic.yml

50 lines
1.1 KiB
YAML
Raw Normal View History

2023-07-21 00:23:22 +00:00
---
- name: Update web servers
hosts: all
remote_user: root
2023-07-21 04:09:23 +00:00
vars:
2023-07-21 04:12:06 +00:00
swapfile_size: 1024
2023-07-21 04:09:23 +00:00
swapfile_path: /swapfile
2023-07-21 00:23:22 +00:00
tasks:
- name: Update all packages to their latest version
ansible.builtin.apt:
name: "*"
state: latest
update_cache: yes
- name: Install a list of packages
ansible.builtin.apt:
pkg:
2023-07-21 03:00:58 +00:00
- htop
2023-07-21 04:09:23 +00:00
- unp
- name: Create swap file
2023-07-21 04:10:55 +00:00
command: dd if=/dev/zero of={{ swapfile_path }} bs=1M count={{ swapfile_size }}
2023-07-21 04:09:23 +00:00
args:
creates: "{{ swapfile_path }}"
register: swapfile_register_create
- name: Set swap file permissions
file:
path: "{{ swapfile_path }}"
state: "file"
owner: "root"
group: "root"
mode: "0600"
- name: Initialize swap file
command: mkswap {{ swapfile_path }}
when: swapfile_register_create is changed
- name: Enable swap file
command: swapon {{ swapfile_path }}
when: swapfile_register_create is changed
- name: Manage swap file in /etc/fstab
mount:
src: "{{ swapfile_path }}"
name: "none"
fstype: "swap"
opts: "sw,nofail"
dump: "0"
passno: "0"
state: "present"