Browse Source

Make possible to add sysfs configuration

Emmanuel Bouthenot 11 years ago
parent
commit
170c9c60c1

+ 9 - 1
roles/common/handlers/base.yml

@@ -1,8 +1,16 @@
 - name: Reload apt cache
   action: command apt-get update
 
-- name: Apply kernel variables
+- name: Apply kernel configuration (proc)
   action: service name=procps state=restarted
 
+- name: Apply kernel configuration (sys)
+  action: service name=sysfsutils state=restarted
+
+- name: Refresh sysfs configuration
+  action: shell cat /etc/sysfs.d/* > /etc/sysfs.conf
+  notify:
+    - Apply kernel configuration (sys)
+
 - name: Update motd
   action: shell toilet -f future ${ansible_fqdn} > /var/run/motd && echo >> /var/run/motd && uname -snrvm >> /var/run/motd && echo >> /var/run/motd

+ 20 - 9
roles/common/tasks/base.yml

@@ -1,3 +1,11 @@
+- name: Install hosts file
+  action: template src=hosts.j2 dest=/etc/hosts owner=root group=root mode=0644
+  notify:
+    - Update motd
+
+- name: Install hosts.deny file
+  action: template src=hosts.deny.j2 dest=/etc/hosts.deny owner=root group=root mode=0644
+
 - name: Write /etc/apt/sources.list
   action: template src=apt/sources.${ansible_lsb.codename}.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
   notify:
@@ -27,21 +35,24 @@
     - pydf
     - htop
     - sudo
+    - sysfsutils
 
-- name: Install hosts file
-  action: template src=hosts.j2 dest=/etc/hosts owner=root group=root mode=0644
+- name: Install kernel configuration (proc)
+  action: template src=kernel/sysctl.d/${item}.j2 dest=/etc/sysctl.d/${item} owner=root group=root mode=0644
+  with_items:
+      - 10-increase-file-descriptors.conf
   notify:
-    - Update motd
+    - Apply kernel configuration (proc)
 
-- name: Install hosts.deny file
-  action: template src=hosts.deny.j2 dest=/etc/hosts.deny owner=root group=root mode=0644
+- name: Create sysfs configuration directory - /etc/sysfs.d
+  action: file path=/etc/sysfs.d state=directory owner=root group=root mode=0755
 
-- name: Install kernel configuration
-  action: template src=kernel/sysctl.d/${item} dest=/etc/sysctl.d/${item} owner=root group=root mode=0644
+- name: Install kernel configuration (sys)
+  action: template src=kernel/sysfs.d/${item}.j2 dest=/etc/sysfs.d/${item} owner=root group=root mode=0644
   with_items:
-      - 10-increase-file-descriptors.conf
+      - 00-sysfs-prolog.conf
   notify:
-    - Apply kernel variables
+    - Refresh sysfs configuration
 
 - name: Install sudo configuration
   action: template src=sudo/local-admin.j2 dest=/etc/sudoers.d/local-admin owner=root group=root mode=0440

+ 0 - 0
roles/common/templates/kernel/sysctl.d/10-increase-file-descriptors.conf → roles/common/templates/kernel/sysctl.d/10-increase-file-descriptors.conf.j2


+ 27 - 0
roles/common/templates/kernel/sysfs.d/00-sysfs-prolog.conf.j2

@@ -0,0 +1,27 @@
+{% if ansible_prolog -%}
+{% from 'templates/ansible/prolog.j2' import prolog with context %}
+{{ prolog() }}
+{% endif -%}
+#
+# /etc/sysfs.conf - Configuration file for setting sysfs attributes.
+#
+# The sysfs mount directory is automatically prepended to the attribute paths.
+#
+# Syntax:
+# attribute = value
+# mode attribute = 0600 # (any valid argument for chmod)
+# owner attribute = root:wheel # (any valid argument for chown)
+#
+# Examples:
+#
+# Always use the powersave CPU frequency governor
+# devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
+#·
+# Use userspace CPU frequency governor and set initial speed
+# devices/system/cpu/cpu0/cpufreq/scaling_governor = userspace
+# devices/system/cpu/cpu0/cpufreq/scaling_setspeed = 600000·
+#
+# Set permissions of suspend control file·
+# mode power/state = 0660
+# owner power/state = root:power
+