volanja / ansible_spec

It's ruby gem that connect Ansible & Serverspec for Test Driven Server Configuration(or TDD).
MIT License
229 stars 57 forks source link

undefined method `to_sym' for nil:NilClass #26

Closed rndmh3ro closed 9 years ago

rndmh3ro commented 9 years ago

The following error occurs when running rake -T. The Rakefile is unchanged.

[localhost]# rake -T --trace
(in /etc/ansible/roles/snmpd)
rake aborted!
undefined method `to_sym' for nil:NilClass
/etc/ansible/roles/snmpd/Rakefile:14
/etc/ansible/roles/snmpd/Rakefile:12:in `each'
/etc/ansible/roles/snmpd/Rakefile:12
/etc/ansible/roles/snmpd/Rakefile:11:in `each'
/etc/ansible/roles/snmpd/Rakefile:11
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1881:in `in_namespace'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:909:in `namespace'
/etc/ansible/roles/snmpd/Rakefile:10
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2382:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2382:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2067:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2015:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1999:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2067:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1997:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

Here are the installed gems:

[localhost]# gem list --local

*** LOCAL GEMS ***

ansible_spec (0.2)
diff-lcs (1.2.5)
hostlist_expression (0.2.1)
json (1.4.6)
multi_json (1.11.2)
net-scp (1.2.1)
net-ssh (2.9.2)
net-telnet (0.1.1)
oj (2.12.9)
rake (0.8.7)
rspec (3.3.0)
rspec-core (3.3.1)
rspec-expectations (3.3.0)
rspec-its (1.2.0)
rspec-mocks (3.3.1)
rspec-support (3.3.0)
safe_yaml (0.9.4)
serverspec (2.19.0)
specinfra (2.36.14)

OS is: RHEL 6.6 Linunx 2.6.32-431.20.3.el6.x86_64 #1 SMP Fri Jun 6 18:30:54 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

volanja commented 9 years ago

Hi @rndmh3ro Please insert line name on your playbook.

Example

- name: Install_Redmine
  hosts: server
  user: root
  roles:
    - packages
    - user
volanja commented 9 years ago

I released v0.2.1 I will warn(rake task aborted & puts message) if no "name" line in playbook.

playbook

- hosts: server
  user: root
  roles:
    - packages
    - user

result

$ rake -T
rake aborted!
Please insert name on playbook
/Users/Adr/.rvm/gems/ruby-2.0.0-p353/gems/ansible_spec-0.2.1/lib/ansible_spec/load_ansible.rb:168:in `load_playbook'
/Users/Adr/.rvm/gems/ruby-2.0.0-p353/gems/ansible_spec-0.2.1/lib/ansible_spec/load_ansible.rb:191:in `get_properties'
/Users/Adr/Development/vagrant_list/ansible-Redmine/Rakefile:6:in `<top (required)>'
/Users/Adr/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
/Users/Adr/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
rndmh3ro commented 9 years ago

Thanks, that fixed it for me!