aboutsummaryrefslogtreecommitdiffstats
path: root/roles/fedora
diff options
context:
space:
mode:
Diffstat (limited to 'roles/fedora')
-rw-r--r--roles/fedora/defaults/main.yml24
-rw-r--r--roles/fedora/handlers/main.yml14
-rw-r--r--roles/fedora/tasks/hosts.yml10
-rw-r--r--roles/fedora/tasks/locale.yml2
-rw-r--r--roles/fedora/tasks/main.yml10
-rw-r--r--roles/fedora/tasks/networkd.yml15
-rw-r--r--roles/fedora/tasks/resolved.yml39
-rw-r--r--roles/fedora/tasks/systemd.yml32
-rw-r--r--roles/fedora/tasks/timesyncd.yml25
-rw-r--r--roles/fedora/tasks/timezone.yml7
-rw-r--r--roles/fedora/templates/hosts.j28
11 files changed, 184 insertions, 2 deletions
diff --git a/roles/fedora/defaults/main.yml b/roles/fedora/defaults/main.yml
index 4304fa0..41944d9 100644
--- a/roles/fedora/defaults/main.yml
+++ b/roles/fedora/defaults/main.yml
@@ -1,4 +1,28 @@
---
+use_resolved: true
+use_networkd: true
+use_timesyncd: true
+
+locale:
+ default:
+ LANG: 'en_US.UTF-8'
+
+systemd_conf: {}
+journald_conf: {}
+logind_conf: {}
+resolved_conf: {}
+timesyncd_conf: {}
+
+dnf_packages:
+ 'glibc-langpack-en': present
+ 'initscripts': present
+ 'hostname': present
+ 'dnf': present
+ 'passwd': present
+ 'vim-enhanced': present
+ 'dnf-command(leaves)': present
+ 'python-unversioned-command': present
+
sudo_group: 'wheel'
# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/handlers/main.yml b/roles/fedora/handlers/main.yml
new file mode 100644
index 0000000..895bad8
--- /dev/null
+++ b/roles/fedora/handlers/main.yml
@@ -0,0 +1,14 @@
+---
+- name: restart resolved
+ systemd:
+ name: systemd-resolved.service
+ state: restarted
+ when: not chroot
+
+- name: restart timesyncd
+ systemd:
+ name: systemd-timesyncd.service
+ state: restarted
+ when: not chroot
+
+# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/tasks/hosts.yml b/roles/fedora/tasks/hosts.yml
new file mode 100644
index 0000000..46299d6
--- /dev/null
+++ b/roles/fedora/tasks/hosts.yml
@@ -0,0 +1,10 @@
+---
+- name: Configure /etc/hosts
+ template:
+ dest: '/etc/hosts'
+ src: hosts.j2
+ owner: root
+ group: root
+ mode: 0644
+
+# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/tasks/locale.yml b/roles/fedora/tasks/locale.yml
index a96d6ba..813abe7 100644
--- a/roles/fedora/tasks/locale.yml
+++ b/roles/fedora/tasks/locale.yml
@@ -1,5 +1,5 @@
---
-- name: Setting default locales
+- name: Setting default locale
template:
dest: '/etc/locale.conf'
src: locale.conf.j2
diff --git a/roles/fedora/tasks/main.yml b/roles/fedora/tasks/main.yml
index 2e163a4..4492df5 100644
--- a/roles/fedora/tasks/main.yml
+++ b/roles/fedora/tasks/main.yml
@@ -1,6 +1,8 @@
---
- import_tasks: dnf.yml
tags: dnf
+- import_tasks: hosts.yml
+ tags: hosts
- import_tasks: timezone.yml
when: timezone is defined
tags: timezone
@@ -10,5 +12,13 @@
- import_tasks: hostname.yml
when: hostname is defined
tags: hostname
+- import_tasks: systemd.yml
+ tags: systemd
+- import_tasks: resolved.yml
+ tags: resolved
+- import_tasks: networkd.yml
+ tags: networkd
+- import_tasks: timesyncd.yml
+ tags: timesyncd
# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/tasks/networkd.yml b/roles/fedora/tasks/networkd.yml
new file mode 100644
index 0000000..de38fa4
--- /dev/null
+++ b/roles/fedora/tasks/networkd.yml
@@ -0,0 +1,15 @@
+---
+- name: Enable/disable systemd-networkd
+ systemd:
+ name: systemd-networkd.service
+ enabled: "{{ use_networkd|ternary('yes','no') }}"
+ masked: "{{ use_networkd|ternary('no',omit) }}"
+ # let the current network daemons run undisturbed until reboot
+ # aka. don't cut the pipe we're connected through
+ #state: "{{ use_networkd|ternary('started','stopped') }}"
+ when: not chroot
+- name: '- when in chroot'
+ command: "systemctl {{ use_networkd|ternary('enable','disable') }} systemd-networkd.service"
+ when: chroot
+
+# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/tasks/resolved.yml b/roles/fedora/tasks/resolved.yml
new file mode 100644
index 0000000..263f93d
--- /dev/null
+++ b/roles/fedora/tasks/resolved.yml
@@ -0,0 +1,39 @@
+---
+- name: Configure systemd-resolved
+ ini_file:
+ path: '/etc/systemd/resolved.conf'
+ no_extra_spaces: yes
+ section: "{{ item.key.split('.',1)[0] }}"
+ option: "{{ item.key.split('.',1)[1] }}"
+ value: "{{ item.value|ternary(item.value,omit) }}"
+ state: "{{ item.value|ternary('present','absent') }}"
+ with_dict: '{{ resolved_conf }}'
+ when: use_resolved
+ notify: restart resolved
+
+- name: Enable/disable systemd-resolved
+ systemd:
+ name: systemd-resolved.service
+ enabled: "{{ use_resolved|ternary('yes','no') }}"
+ masked: no
+ state: "{{ use_resolved|ternary('started','stopped') }}"
+ when: not chroot
+- name: '- when in chroot'
+ command: 'systemctl {{ use_resolved|ternary("enable","disable") }} systemd-resolved.service'
+ when: chroot
+
+- name: Symlink /etc/resolv.conf
+ file:
+ path: '/etc/resolv.conf'
+ src: '/run/systemd/resolve/resolv.conf'
+ state: link
+ force: yes
+ when: use_resolved
+- name: Use myhostname and possibly resolved nss plugins
+ lineinfile:
+ path: /etc/nsswitch.conf
+ regexp: '^hosts:'
+ line: 'hosts: files resolve [!UNAVAIL=return] dns myhostname'
+ when: use_resolved
+
+# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/tasks/systemd.yml b/roles/fedora/tasks/systemd.yml
new file mode 100644
index 0000000..56a5898
--- /dev/null
+++ b/roles/fedora/tasks/systemd.yml
@@ -0,0 +1,32 @@
+---
+- name: Configure systemd system.conf
+ ini_file:
+ path: '/etc/systemd/system.conf'
+ no_extra_spaces: yes
+ section: "{{ item.key.split('.',1)[0] }}"
+ option: "{{ item.key.split('.',1)[1] }}"
+ value: "{{ item.value|ternary(item.value,omit) }}"
+ state: "{{ item.value|ternary('present','absent') }}"
+ with_dict: '{{ systemd_conf }}'
+
+- name: Configure journald.conf
+ ini_file:
+ path: '/etc/systemd/journald.conf'
+ no_extra_spaces: yes
+ section: "{{ item.key.split('.',1)[0] }}"
+ option: "{{ item.key.split('.',1)[1] }}"
+ value: "{{ item.value|ternary(item.value,omit) }}"
+ state: "{{ item.value|ternary('present','absent') }}"
+ with_dict: '{{ journald_conf }}'
+
+- name: Configure logind.conf
+ ini_file:
+ path: '/etc/systemd/logind.conf'
+ no_extra_spaces: yes
+ section: "{{ item.key.split('.',1)[0] }}"
+ option: "{{ item.key.split('.',1)[1] }}"
+ value: "{{ item.value|ternary(item.value,omit) }}"
+ state: "{{ item.value|ternary('present','absent') }}"
+ with_dict: '{{ logind_conf }}'
+
+# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/tasks/timesyncd.yml b/roles/fedora/tasks/timesyncd.yml
new file mode 100644
index 0000000..63949fc
--- /dev/null
+++ b/roles/fedora/tasks/timesyncd.yml
@@ -0,0 +1,25 @@
+---
+- name: Configure systemd-timesyncd
+ ini_file:
+ path: '/etc/systemd/timesyncd.conf'
+ no_extra_spaces: yes
+ section: "{{ item.key.split('.',1)[0] }}"
+ option: "{{ item.key.split('.',1)[1] }}"
+ value: "{{ item.value|ternary(item.value,omit) }}"
+ state: "{{ item.value|ternary('present','absent') }}"
+ with_dict: '{{ timesyncd_conf }}'
+ when: use_timesyncd
+ notify: restart timesyncd
+
+- name: Enable systemd-timesyncd
+ systemd:
+ name: systemd-timesyncd.service
+ enabled: "{{ use_timesyncd|ternary('yes','no') }}"
+ masked: no
+ state: "{{ use_timesyncd|ternary('started','stopped') }}"
+ when: not chroot
+- name: '- when in chroot'
+ command: systemctl enable systemd-timesyncd.service
+ when: chroot
+
+# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/tasks/timezone.yml b/roles/fedora/tasks/timezone.yml
index 90c2344..a917dd4 100644
--- a/roles/fedora/tasks/timezone.yml
+++ b/roles/fedora/tasks/timezone.yml
@@ -1,9 +1,14 @@
---
-- name: Create /etc/localtime
+- name: Configure timezone
+ timezone:
+ name: '{{ timezone }}'
+ when: not chroot
+- name: '- when in chroot'
file:
path: '/etc/localtime'
src: '../usr/share/zoneinfo/{{ timezone }}'
state: link
force: yes
+ when: chroot
# vim: set ts=2 sw=2 et:
diff --git a/roles/fedora/templates/hosts.j2 b/roles/fedora/templates/hosts.j2
new file mode 100644
index 0000000..695442d
--- /dev/null
+++ b/roles/fedora/templates/hosts.j2
@@ -0,0 +1,8 @@
+127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
+::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
+{% if hosts is defined %}
+
+{% for addr, names in hosts %}
+{{ addr }} {{ names|join(' ') }}
+{% endfor %}
+{% endif %}