Using 2 inventories. Can someone explain what I'm doing wrong?

26 views
Skip to first unread message

Varun Chopra

unread,
Feb 13, 2018, 11:06:35 AM2/13/18
to Ansible Project
So I plan to use a static and a dynamic inventory (gce) and this is what my play folder looks like:

.
├── ansible.cfg
├── credentials.json
├── gce_vars
  ├── auth
  └── test_servers
├── group_vars
  └── all
├── hosts.yml
├── inventory
  ├── gce.ini
  ├── gce.py
  └── hosts.yml
└── provision.yml

3 directories, 10 files


credentials.json is the json private key for my service account.

[root@workstation gcloud]# cat gce_vars/auth
---
service_account_email
: "XXXXX-...@developer.gserviceaccount.com"
path_to_credentials
: /workspace/gcloud/credentials.json
project_id
: "heroic-XXX-XXX"
...

gce.ini

[gce]
libcloud_secrets
=
gce_service_account_email_address
= XXXXX-compute@developer.gserviceaccount.com
gce_service_account_pem_file_path
= /workstation/gcloud/credentials.json
gce_project_id
= heroic-XXX-XXX

[inventory]
inventory_ip_type
= external

[cache]
cache_path
= ~/.ansible/tmp
cache_max_age
= 300

However, when I try to run the dynamic inventory, I get this error:

[root@workstation inventory]# ./gce.py --list
Traceback (most recent call last):
  File "./gce.py", line 508, in <module>
    GceInventory()
  File "./gce.py", line 170, in __init__
    self.driver = self.get_gce_driver()
  File "./gce.py", line 318, in get_gce_driver
    gce = get_driver(Provider.GCE)(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py", line 1795, in __init__
    super(GCENodeDriver, self).__init__(user_id, key, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/common/base.py", line 975, in __init__
    self.connection = self.connectionCls(*args, **conn_kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py", line 99, in __init__
    credential_file=credential_file, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 767, in __init__
    user_id, key, auth_type, credential_file, scopes, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 653, in __init__
    self.user_id, self.key, self.scopes, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 495, in __init__
    "file: '%s'" % key)
ValueError: Missing (or not readable) key file: '/workstation/gcloud/credentials.json'


Vyacheslav

unread,
Feb 13, 2018, 12:38:42 PM2/13/18
to Ansible Project

>  Missing (or not readable) key file: '/workstation/gcloud/credentials.json'

what says ls -la /workstation/gcloud | grep credentials.json ?

Varun Chopra

unread,
Feb 13, 2018, 2:07:26 PM2/13/18
to Ansible Project
Thanks. I read your post and realized what I did wrong.

/workspace was my working directory and workstation's my hostname. Mixed up the two. :l
Reply all
Reply to author
Forward
0 new messages