summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/hostname/README.md7
-rw-r--r--roles/hostname/meta/argument_specs.yml7
-rw-r--r--roles/hostname/meta/main.yml19
-rw-r--r--roles/hostname/tasks/main.yml22
-rw-r--r--roles/network/README.md1
-rw-r--r--roles/network/meta/argument_specs.yml3
-rw-r--r--roles/network/tasks/main.yml23
7 files changed, 55 insertions, 27 deletions
diff --git a/roles/hostname/README.md b/roles/hostname/README.md
new file mode 100644
index 00000000..352b6259
--- /dev/null
+++ b/roles/hostname/README.md
@@ -0,0 +1,7 @@
+# Ansible Role: hostname
+
+This role configure the hostname and host files on a linux distro
+
+## Role Variables
+
+- `hostname` the hostname to be configure if provided.
diff --git a/roles/hostname/meta/argument_specs.yml b/roles/hostname/meta/argument_specs.yml
new file mode 100644
index 00000000..d74f95e5
--- /dev/null
+++ b/roles/hostname/meta/argument_specs.yml
@@ -0,0 +1,7 @@
+---
+argument_specs:
+ main:
+ options:
+ hostname:
+ type: "str"
+ description: "The distro linux network hostname to be used"
diff --git a/roles/hostname/meta/main.yml b/roles/hostname/meta/main.yml
new file mode 100644
index 00000000..94c03b4d
--- /dev/null
+++ b/roles/hostname/meta/main.yml
@@ -0,0 +1,19 @@
+---
+dependencies: []
+galaxy_info:
+ role_name: hostname
+ author: a14m
+ description: "Configure basic distro hostname"
+ company: "kartoffeln.work GmbH."
+ license: "license MIT"
+ min_ansible_version: "2.18"
+ platforms:
+ - name: ArchLinux
+ versions:
+ - all
+ - name: Ubuntu
+ versions:
+ - noble
+ - name: Debian
+ versions:
+ - bookworm
diff --git a/roles/hostname/tasks/main.yml b/roles/hostname/tasks/main.yml
new file mode 100644
index 00000000..b6dc2cc1
--- /dev/null
+++ b/roles/hostname/tasks/main.yml
@@ -0,0 +1,22 @@
+---
+- name: "Configure /etc/hostname"
+ become: true
+ ansible.builtin.copy:
+ dest: "/etc/hostname"
+ mode: "0644"
+ content: |
+ {{ hostname }}
+ when: hostname is defined
+
+- name: "Configure /etc/hosts"
+ become: true
+ ansible.builtin.copy:
+ dest: "/etc/hosts"
+ mode: "0644"
+ content: |
+ 127.0.0.1 localhost
+ 127.0.1.1 {{ hostname }}
+ ::1 localhost ip6-localhost ip6-loopback
+ ff02::1 ip6-allnodes
+ ff02::2 ip6-allrouters
+ when: hostname is defined
diff --git a/roles/network/README.md b/roles/network/README.md
index ef0a566d..f66857c2 100644
--- a/roles/network/README.md
+++ b/roles/network/README.md
@@ -4,7 +4,6 @@ This role configure the basic networking functionality of a linux distro
## Role Variables
-- `hostname` the hostname to be configure if provided.
- `network_wifi_ssid` the name of the WIFI network to be configured (default: "").
- `network_wifi_pass` the passphrase of the WIFI network to be configure (default: "").
- `network_packages` the packages to install for a distro (default in distro vars).
diff --git a/roles/network/meta/argument_specs.yml b/roles/network/meta/argument_specs.yml
index cd30b69c..33561c8d 100644
--- a/roles/network/meta/argument_specs.yml
+++ b/roles/network/meta/argument_specs.yml
@@ -2,9 +2,6 @@
argument_specs:
main:
options:
- hostname:
- type: "str"
- description: "The distro linux network hostname to be used"
network_wifi_ssid:
type: "str"
description: "The WIFI SSID to be configure when provided"
diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml
index 2bebaf22..c45cb6da 100644
--- a/roles/network/tasks/main.yml
+++ b/roles/network/tasks/main.yml
@@ -5,29 +5,6 @@
- name: "Include OS-specific tasks"
ansible.builtin.include_tasks: "install-{{ ansible_os_family | lower }}.yml"
-- name: "Configure /etc/hostname"
- become: true
- ansible.builtin.copy:
- dest: "/etc/hostname"
- mode: "0644"
- content: |
- {{ hostname }}
- when: hostname is defined
-
-- name: "Configure /etc/hosts"
- become: true
- ansible.builtin.copy:
- dest: "/etc/hosts"
- mode: "0644"
- content: |
- 127.0.0.1 localhost
- 127.0.1.1 {{ hostname }}
- ::1 localhost ip6-localhost ip6-loopback
- ff02::1 ip6-allnodes
- ff02::2 ip6-allrouters
- when: hostname is defined
- # Not required for boot
-
- name: "(chroot): Ensure network_services are enabled"
ansible.builtin.command:
cmd: "systemctl enable {{ item }}"