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

exception dynamic inventory when subfolders #194

Open
Anasme opened this issue Apr 5, 2019 · 5 comments
Open

exception dynamic inventory when subfolders #194

Anasme opened this issue Apr 5, 2019 · 5 comments
Labels

Comments

@Anasme
Copy link

Anasme commented Apr 5, 2019

Hello,

I'm trying ansible-cmdb and it seem very nice, thank you.
Unfortunately I encounter an error when reading my inventory:

[root@server:~]# ansible-cmdb -i /etc/ansible/inventories/prod out/ > overview.html
Exception while executing dynamic inventory script '/etc/ansible/inventories/prod/hosts':
[Errno 8] Exec format error
Traceback (most recent call last):
File "/usr/local/bin/../lib/ansiblecmdb/ansible-cmdb.py", line 205, in
limit=options.limit, debug=options.debug)
File "/usr/local/lib/python2.7/dist-packages/ansiblecmdb/ansible.py", line 61, in init
self._parse_hostvar_dir(inventory_path)
File "/usr/local/lib/python2.7/dist-packages/ansiblecmdb/ansible.py", line 188, in _parse_hostvar_dir
self._parse_hostvar_file(hostname, p)
File "/usr/local/lib/python2.7/dist-packages/ansiblecmdb/ansible.py", line 196, in _parse_hostvar_file
first_line = open(path, 'r').readline()
IOError: [Errno 21] Is a directory: '/etc/ansible/inventories/prod/host_vars/FQDN/vault'

my inventories tree look like this (exemple of course):
in host_vars I have some server with 2 subfolders like ./server/vars ./server/vault

.
├── group_vars
│   ├── all
│   │   └── 000_cross_env_vars -> ../../../000_cross_env_vars
│   ├── prod_censored_ab
│   │   ├── dns.yml
│   │   └── censored.yml
│   ├── prod_censored_am_expert
│   │   ├── parameters.yml
│   │   └── censored.yml
│   ├── prod_censored_am_pro
│   │   ├── dns.yml
│   │   ├── document.yml
│   │   ├── nginx_vhosts.yml
│   │   ├── parameters.yml
│   │   └── censored.yml
│   ├── prod_censored_xyxyx
│   │   └── document.yml
│   ├── prod_censored_xyxyxy
│   │   └── censored.yml
│   ├── prod_censored_xyxy
│   │   └── censored.yml
│   ├── prod_censored_xyx
│   │   ├── document.yml
│   │   └── censored.yml
│   ├── prod_censored_yy
│   │   ├── document.yml
│   │   └── censored.yml
│   ├── prod_censored_x
│   │   └── censored.yml
│   ├── prod_censored_xy
│   │   ├── dns.yml
│   │   └── censored.yml
│   ├── prod_soft_gitlab
│   │   └── dns.yml
│   └── prod_soft_vc
│   ├── dns.yml
│   └── nginx.yml
├── hosts
└── host_vars
├── server1
│   ├── vars
│   └── vault
├── server2
│   ├── censored.yml
│   └── vault
├── server3
│   ├── dns.yml
│   ├── document.yml
│   ├── nginx.yml
│   ├── censored.yml
│   └── vault
├── server4
│   ├── vars
│   └── vault
├── server5
│   ├── vars
│   └── vault
├── server6
│   ├── vars
│   └── vault
├── server7
│   ├── vars
│   └── vault
├── server8
│   ├── vars
│   └── vault

I want to create a cmdb with your tools to retrieve the basic information that you propose, add all the variables by groups/hosts and some additional facts that I could automate (apache version, tomcat etc.)

Thank a lot for your future help

@fboender
Copy link
Owner

fboender commented Apr 6, 2019

Hi Anasme!

I'm not sure, but it looks like you're specifying a path to a directory for the -i param, instead of pointing it to the hosts file. If you point -i to the hosts file as shown in your directory listing, it will automatically pick up the group_vars and host_vars dirs in that same dir.

Can you try something like?:

ansible-cmdb -i /etc/ansible/inventories/prod/hosts out/ > overview.html

If that still gives errors, let me know, and I can look into it.

@fboender
Copy link
Owner

fboender commented Apr 7, 2019

Confirmed that this is a bug in ansible-cmdb.

@fboender fboender added the bug label Apr 7, 2019
@fboender
Copy link
Owner

fboender commented Apr 7, 2019

For now I've "fixed" this by skipping directories in host_vars. Not really a fix, but I'm reworking the parsing of host/group vars and don't want to invest time in properly parsing the myriad of exceptions and hidden features in Ansible inventories in the old code.

@Anasme
Copy link
Author

Anasme commented Apr 9, 2019

For now I've "fixed" this by skipping directories in host_vars. Not really a fix, but I'm reworking the parsing of host/group vars and don't want to invest time in properly parsing the myriad of exceptions and hidden features in Ansible inventories in the old code.

Hey ! Thank for your reply. Nice to hear you are reworking this part :), I will wait for it, I'm on another project atm. I stay tunned !

@Anasme
Copy link
Author

Anasme commented May 27, 2019

hey @fboender , how are you?
what's new on the redesign of your ansible-cmdb?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants