Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

set hostname to multiple hosts using ansible #254

Open
shri-1994 opened this issue Jul 11, 2019 · 2 comments
Open

set hostname to multiple hosts using ansible #254

shri-1994 opened this issue Jul 11, 2019 · 2 comments

Comments

@shri-1994
Copy link

No description provided.

@shri-1994
Copy link
Author

I have server which i want set the hostnames like webserver01,02,03....n.
How should I make the playbook and also inventory.

@omwaskar
Copy link

PLAYBOOK


  • hosts: all
    vars_files:
    • /vars/host.yml
      tasks:
    • hostname:
      name: "{{item.name}}"
      when: "{{ansible_hostname == item.host}}"
      with_items: "{{hostinfo}}"

VARS_FILES

hostinfo:

  • host: classroom1
    name: webserver01
  • host: classroom2
    name: webserver02
    .
    .
    and so on
  • host: "old hostname"
    name: "new hostname"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants