Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codylane/ansible-playbook-change-hostname
A ansible playbook to help fix /etc/hosts, re-name your hostname, reboot and validate. Yay!
https://github.com/codylane/ansible-playbook-change-hostname
Last synced: 4 days ago
JSON representation
A ansible playbook to help fix /etc/hosts, re-name your hostname, reboot and validate. Yay!
- Host: GitHub
- URL: https://github.com/codylane/ansible-playbook-change-hostname
- Owner: codylane
- License: mit
- Created: 2016-10-20T21:20:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-21T21:41:45.000Z (almost 4 years ago)
- Last Synced: 2023-08-03T01:12:11.269Z (over 1 year ago)
- Homepage: https://github.com/codylane/ansible-playbook-change-hostname
- Size: 3.91 KB
- Stars: 25
- Watchers: 2
- Forks: 22
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: change_hostname.yaml
- License: LICENSE
Awesome Lists containing this project
README
# ansible-playbook-change-hostname
A ansible playbook to help fix /etc/hosts# Overview
This was created from some snippets I found online and put it all together in a single place. This is really just here for my own reference.Here are the links that I owe credit to:
* https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back# Howto use this playbook
## Define an inventory file in your current directory
```
[all]
foo-app-01.example.com
foo-app-02.example.com
foo-app-03.example.com
foo-app-03.example.com
```So, in order for this to work `foo-app*.example.com` must be resolvable by DNS and these are the values you want your hostnames to become. If your hosts are not resolvable in DNS you can create a node alias in your inventory file as follows.
```
[all]
foo-app-01.example.com ansible_ssh_host=1.2.3.4
foo-app-02.example.com ansible_ssh_host=1.2.3.5
foo-app-03.example.com ansible_ssh_host=1.2.3.6
foo-app-03.example.com ansible_ssh_host=1.2.3.7
```After your hostnames are updated, you can also pass a parameter on the command line to reboot. Here's how to do that.
```
ansible-playbook -e 'reboot=True' -i inventory change_hostname.yaml
```Finally, if all goes well the last step is a vaildation routine that makes sure your remote clients hostname matches your `inventory_hostname` you defined in your inventory. You might need to blow away the `tmp/ansible-facts` cache dir for this to succeed, however.