Setting hostname

124 views
Skip to first unread message

Kuberboef

unread,
Sep 14, 2015, 8:20:06 AM9/14/15
to Ansible Project

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

Frank Perks

unread,
Sep 14, 2015, 12:01:34 PM9/14/15
to Ansible Project
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

Kuberboef

unread,
Sep 15, 2015, 1:41:52 AM9/15/15
to Ansible Project

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
--------------

 * *hostname_name* - new hostname (not FQDN, before first dot)
 * *hostname_domain* - new domain name

Config in vars/main.yml:

---
# vars file for hostname

  hostname_name = mozzi
  hostname_domain = mozzi.mydomain.com

Error I get:


ERROR: vars from '/home/stefaansm/trusty64/Ansible/ansible-hostname/vars/main.yml' are not a dict

How do I make this a dict?

Again apologies for such a n00b question.

Frank Perks

unread,
Sep 15, 2015, 8:58:38 AM9/15/15
to Ansible Project
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. 

Paul Markham

unread,
Sep 21, 2015, 1:49:25 AM9/21/15
to Ansible Project
YAML doesn't use an equals sign, instead use a colon:

---
  hostname_name: mozzi
  hostname_domain
: mozzi.mydomain.com

stefaans...@gmail.com

unread,
Sep 21, 2015, 2:19:26 AM9/21/15
to ansible...@googlegroups.com
Thanx mate, figured that one out the hard way! :D

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/_h-dzqHYejQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ffafe488-378f-48c4-a77d-b7885f6928fa%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
J Stefaans Mostert
Mobile: 0844634590
Fax: 0867300603
skype: mozzi_za (kuberboef)

Linux is simple. It just takes a genius to understand its simplicity.
Reply all
Reply to author
Forward
0 new messages