Setting hostname

Morning all

I am sure this has been asked before, I just struggle to find it.
I cloned https://github.com/knopki/ansible-hostname
Looks good and vagrant calls ansible successfully and all goes wel, untill…
I need to specify variables in the vars/main.yml file.

hostname_name = mozzi
hostname_domain = mozzi.mydomain.com

My error:
ERROR: vars from ‘/home/stefaansm/trusty64/Ansible/ansible-hostname/vars/main.yml’ are not a dict

Now being a nube at this and not a programmers backside, I seem to be lost here and doc’s seem scarce.

Mozzi

ansible-hostname is a role, and should be in the roles directory.

Assuming /home/stefaansm/trusty64/Ansible/ is where your playbooks are. Then ansible-hostname should be located at /home/stefaansm/trusty64/Ansible/roles/ansible-hostname

Morning

Okay contents of ~/trusty64/Ansible
Ansible
│ ├── ansible-hostname
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── LICENSE
│ │ ├── meta
│ │ │ └── main.yml
│ │ ├── README.md
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── vars
│ │ └── main.yml

│ └── playbook.yml

config in playbook:

  • hosts: all
    roles:
  • { role: ansible-hostname }

So according to me the role is found and executed correctly, but there is something wrong
with the way I specify the hostnames in vars/main.yml.

From the README.md:

Role Variables

Like i said move your ansible-hostname into the roles folder (if you don’t have one make one). As far as i know ansible only loads roles from the roles folder, which is probably your issue.

Also his documentation is wrong, he doesn’t use hostname_domain, he actually in the code uses hostname_fqdn instead.

YAML doesn’t use an equals sign, instead use a colon:

Thanx mate, figured that one out the hard way! :smiley: