Created
February 26, 2021 16:41
-
-
Save psct/cbccbeeac6b4262abba367a2d990833e to your computer and use it in GitHub Desktop.
Debian set hostname and adjust /etc/hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: set name, adjust /etc/hosts | |
hosts: all | |
become: yes | |
# order matters! | |
tasks: | |
- name: adjust /etc/hosts | |
replace: | |
path: /etc/hosts | |
regexp: '(\s*){{ ansible_hostname }}(\s*)' | |
replace: '\1{{ hostname }}\2' | |
- name: set hostname | |
hostname: | |
name: '{{ hostname }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment