diff --git a/disableswap.yml b/disableswap.yml new file mode 100644 index 0000000..b476ada --- /dev/null +++ b/disableswap.yml @@ -0,0 +1,7 @@ +--- +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - disableswap + diff --git a/hosts b/hosts index f288a00..edb0a94 100644 --- a/hosts +++ b/hosts @@ -11,6 +11,7 @@ pis: julius: carl: cleatus: + selma: # barney: vars: ansible_python_interpreter: /usr/bin/python3 diff --git a/initpi.yml b/initpi.yml index 1649ac2..ced8ba4 100644 --- a/initpi.yml +++ b/initpi.yml @@ -5,4 +5,5 @@ roles: - initpi - log2ram + - disableswap diff --git a/resources/dphys-swapfile b/resources/dphys-swapfile new file mode 100644 index 0000000..d47a28d --- /dev/null +++ b/resources/dphys-swapfile @@ -0,0 +1,26 @@ +# /etc/dphys-swapfile - user settings for dphys-swapfile package +# author Neil Franklin, last modification 2010.05.05 +# copyright ETH Zuerich Physics Departement +# use under either modified/non-advertising BSD or GPL license + +# this file is sourced with . so full normal sh syntax applies + +# the default settings are added as commented out CONF_*=* lines + + +# where we want the swapfile to be, this is the default +#CONF_SWAPFILE=/var/swap + +# set size to absolute value, leaving empty (default) then uses computed value +# you most likely don't want this, unless you have an special disk situation +CONF_SWAPSIZE=0 + +# set size to computed value, this times RAM size, dynamically adapts, +# guarantees that there is enough swap without wasting disk space on excess +#CONF_SWAPFACTOR=2 + +# restrict size (computed and absolute!) to maximally this limit +# can be set to empty for no limit, but beware of filled partitions! +# this is/was a (outdated?) 32bit kernel limit (in MBytes), do not overrun it +# but is also sensible on 64bit to prevent filling /var or even / partition +#CONF_MAXSWAP=2048 diff --git a/roles/disableswap/tasks/main.yml b/roles/disableswap/tasks/main.yml new file mode 100644 index 0000000..878314e --- /dev/null +++ b/roles/disableswap/tasks/main.yml @@ -0,0 +1,19 @@ +- name: Disable swap. + shell: > + dphys-swapfile swapoff && + dphys-swapfile uninstall && + update-rc.d -f dphys-swapfile remove + systemctl disable dphys-swapfile +# when: +# - ansible_swaptotal_mb > 0 +- name: copy dphys-swapfile + become: true + copy: + src: resources/{{ item }} + dest: /etc + owner: root + group: root + mode: '0744' + with_items: + - dphys-swapfile + diff --git a/roles/initpi/tasks/main.yml b/roles/initpi/tasks/main.yml index 5694274..2d7a53a 100644 --- a/roles/initpi/tasks/main.yml +++ b/roles/initpi/tasks/main.yml @@ -31,6 +31,8 @@ - docker.io - git - locate + - yum + - dnsutils - nfs-kernel-server update_cache: yes cache_valid_time: 86400