Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants