feat(hostname): support partial execution with prepare and deploy tags

This commit is contained in:
transcaffeine 2021-05-26 14:30:51 +02:00
parent 3803a5931d
commit 7ae06507c1
No known key found for this signature in database
GPG key ID: 03624C433676E465

View file

@ -8,6 +8,7 @@
mode: 0644
content: |
{{ hostname_fqdn }}
tags: [ 'deploy', 'deploy-hostname' ]
- name: Ensure /etc/hosts contains all hostnames and aliases of the server
blockinfile:
@ -20,6 +21,7 @@
{{ host.ip }} {{ host.fqdn }} {{ host.alias | default([]) | join(" ") }}
{% endfor %}
marker: "# {mark} ANSIBLE MANAGED BLOCK"
tags: [ 'deploy', 'deploy-hostname' ]
# Needed because ansibles `ansible_fqdn` is loaded
# from /etc/hostname, not from the running hostname
@ -28,6 +30,7 @@
cmd: "hostname"
changed_when: false
register: current_hostname
tags: [ 'deploy', 'deploy-hostname' ]
- name: Set hostname via hostnamectl to avoid a reboot
command:
@ -35,3 +38,4 @@
when: hostname_fqdn != hostname_current
vars:
hostname_current: "{{ current_hostname.stdout }}."
tags: [ 'deploy', 'deploy-hostname' ]