Skip to content

Using hostname module raises an error #5304

@jiv-e

Description

@jiv-e

I tried to use the hostname module but it raises an error.

ERROR: hostname is not a legal parameter in an Ansible task or handler

See: http://www.ansibleworks.com/docs/modules.html#hostname

I ran this command:

$ ansible-playbook -i hosts test.yml --private-key=~/.vagrant.d/insecure_private_key

Here's my hosts file:

[dev]
192.168.56.102

Here's my test.yml file:

---
- hosts: dev
  user: vagrant
  tasks:
    - ping:
    - hostname: name=newname

Ping works, but as soon as I add the hostname call the error is raised.

I'm on the devel branch 1.4.1 release. See also...

$ which ansible-playbook
/usr/local/bin/ansible-playbook
$ ansible-playbook --version
ansible-playbook 1.4
$ git log -- library/system/hostname
commit cc3678730c97244efe1e8a2a5b1b0b323a7beb7a
Author: David Hummel <david_hummel@hms.harvard.edu>
Date:   Sat Dec 7 21:10:42 2013 -0500

    Fix issue #5214: hostname persistence on RedHat/CentOS
$ python --version
Python 2.7.5

I'm using a clean vagrant precise64 box. Here's the vagrantfile...

Vagrant.configure("2") do |config|
  config.vm.box = "UbuntuPrecise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"

  config.vm.network "private_network", ip: "192.168.56.102"

  config.vm.synced_folder "~/Sites/test", "/var/www", id: "vagrant-root", :nfs => false

  config.vm.usable_port_range = (2200..2250)
  config.vm.provider :virtualbox do |virtualbox|
    virtualbox.customize ["modifyvm", :id, "--name", "test"]
    virtualbox.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    virtualbox.customize ["modifyvm", :id, "--memory", "2048"]
    virtualbox.customize ["setextradata", :id, "--VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
  end

  config.ssh.username = "vagrant"

  config.ssh.shell = "bash -l"

  config.ssh.keep_alive = true
  config.ssh.forward_agent = false
  config.ssh.forward_x11 = false
  config.vagrant.host = :detect
end

I'm using Mac OS X Mavericks as my local machine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions