Code Monkey home page Code Monkey logo

ansible-playbook-change-hostname's Introduction

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:

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.

ansible-playbook-change-hostname's People

Contributors

codylane avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.