diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-31 08:53:50 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-31 08:53:50 +0300 |
commit | 1c461a80c791253ef27be98ccf8c88fe6133a4f2 (patch) | |
tree | de8669f11e1d6f483cd3cf76ca91cb7c43a60758 /roles | |
parent | f1a3416db0fbf0b62af8c45cd11f66018d00ff41 (diff) | |
download | debian-ansible-1c461a80c791253ef27be98ccf8c88fe6133a4f2.tar.gz |
feat! default sane_debian_hostname to inventory hostname
Doesn't break anything if hostname was already set, but just in case,
bump version number, which means any users of this role need to be
upgraded.
Diffstat (limited to 'roles')
-rw-r--r-- | roles/sane_debian_system/defaults/main.yml | 4 | ||||
-rw-r--r-- | roles/sane_debian_system/subplot.md | 28 | ||||
-rw-r--r-- | roles/sane_debian_system/tasks/main.yml | 2 |
3 files changed, 29 insertions, 5 deletions
diff --git a/roles/sane_debian_system/defaults/main.yml b/roles/sane_debian_system/defaults/main.yml index 43d0262..5ef7537 100644 --- a/roles/sane_debian_system/defaults/main.yml +++ b/roles/sane_debian_system/defaults/main.yml @@ -1,8 +1,8 @@ # These are the variables expected by this role. # Playbook should set this to the version of this role it expects to -# use. -sane_debian_system_version: null +# use. Defaults to the inventory hostname. +sane_debian_system_version: "{{ inventory_hostname }}" # The desired hostname. Default is empty, which means hostname won't diff --git a/roles/sane_debian_system/subplot.md b/roles/sane_debian_system/subplot.md index 087ae44..dc22679 100644 --- a/roles/sane_debian_system/subplot.md +++ b/roles/sane_debian_system/subplot.md @@ -3,6 +3,13 @@ This role sets up a Debian system so that it can be managed with Ansible in a reasonable way. +## Version history + +### Version 2 + +* `sane_debian_hostname` defaults to the inventory hostname. This + means it's not necessary to set it if the default is sufficient. + ## Minimally sane Debian system ~~~scenario @@ -20,12 +27,29 @@ and the host has saneone in /etc/hosts for 127.0.1.1 ~~~ ~~~{#sane1.yml .file .yaml} -sane_debian_system_version: 1 +sane_debian_system_version: 2 sane_debian_system_codename: buster sane_debian_system_hostname: saneone ~~~ +## Uses inventory hostname by default + +~~~scenario +given a host running Debian +when I use role sane_debian_system +and I use variables from sane-without-hostname.yml +and I run the playbook +then the host has the sudo package installed +and the host has hostname debian-ansible-test +~~~ + +~~~{#sane-without-hostname.yml .file .yaml} +sane_debian_system_version: 2 + +sane_debian_system_codename: buster +~~~ + ## Checks that debian codename is set ~~~scenario @@ -38,5 +62,5 @@ and stdout contains "sane_debian_system_codename" ~~~ ~~~{#sane2.yml .file .yaml} -sane_debian_system_version: 1 +sane_debian_system_version: 2 ~~~ diff --git a/roles/sane_debian_system/tasks/main.yml b/roles/sane_debian_system/tasks/main.yml index 7722f1c..30a3f0c 100644 --- a/roles/sane_debian_system/tasks/main.yml +++ b/roles/sane_debian_system/tasks/main.yml @@ -1,6 +1,6 @@ - name: "sane_debian_system_version" shell: | - [ "{{ sane_debian_system_version }}" = "1" ] || \ + [ "{{ sane_debian_system_version }}" = "2" ] || \ (echo "Unexpected version {{ sane_debian_system_version }}" 1>&2; exit 1) - include: apt.yml |