-2

trying to ping-pong all instances in the group, using virtualenv where I have installed all the needed packages with a makefile. I cloned repository of my project, so I need to say that this is work on my colleagues' laptops(mac intel), but not on mine(mac m2).

using ansible all -i ./inventories/infra-dev/ -m ping

Getting this output

[WARNING]:  * Failed to parse /<some>/<some>/<some>/<some>-ansible/inventories/infra-dev/infra_dev_gcp.yaml with auto plugin: Invalid control character at: line 5 column 38 (char 170)

[WARNING]:  * Failed to parse /<some>/<some>/<some>/<some>-ansible/inventories/infra-dev/infra_dev_gcp.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory

[WARNING]:  * Failed to parse /<some>/<some>/<some>/<some>-ansible/inventories/infra-dev/infra_dev_gcp.yaml with ini plugin: Invalid host pattern '---' supplied, '---' is normally a sign this is a YAML
file.

[WARNING]: Unable to parse /<some>/<some>/<some>/<some>-ansible/inventories/infra-dev/infra_dev_gcp.yaml as an inventory source

[WARNING]: Unable to parse /<some>/<some>/<some>/<some>-ansible/inventories/infra-dev as an inventory source

ERROR! No inventory was parsed, please check your configuration and options. 

Versions:

Package        Version
-------------- ---------
ansible        2.9.1
cachetools     4.2.4
certifi        2022.9.24
cffi           1.15.1
chardet        3.0.4
cryptography   38.0.3
google-auth    1.23.0
idna           2.10
Jinja2         3.1.2
MarkupSafe     2.1.1
pathspec       0.10.1
pip            22.3
pyasn1         0.4.8
pyasn1-modules 0.2.8
pycparser      2.21
PyYAML         6.0
requests       2.25.0
rsa            4.9
setuptools     65.5.0
six            1.16.0
urllib3        1.26.12
wheel          0.37.1
yamllint       1.23.0

And the inventory file:

plugin: gcp_compute
projects:
  - <some>-<some>-<some>
keyed_groups:
  - prefix: "gcp"
    key: labels['group']
filters:
  - labels.ecosystem = "dev" AND labels.ecolevel = "infra-dev"
auth_kind: serviceaccount
service_account_file: ~/.<some>/<some>-<some>-<some>.json
hostnames:
  - name
compose:
  ansible_host: networkInterfaces[0].networkIP
DISCO
  • 135
  • 12
  • Thank you, refactored the question, the key point that this is works on other laptops, but not on mine, so I think that if the problem is in the inventory name that won`t work on other laptops too. – DISCO Nov 03 '22 at 15:53
  • 1
    I can't reproduce your problem. The yaml file is correctly parsed if I provide a correct service account file and project name. I get an empty result because I have no gcp ressources live but I don't have any warning nor errors. `the service account file is good because given by a collegue of mine` is not an acceptable affirmation. It could have been altered during transfer or could suffer a charset issue. I'm quite sure if you look at that file at line 5 column 38 you''ll find something weird. Get a new one from source. – Zeitounator Nov 03 '22 at 16:59
  • you are right, there was a missing whitespace in service account config... – DISCO Nov 03 '22 at 17:20

1 Answers1

1

Maybe your service account file is wrong or does not exist:

service_account_file: ~/.<some>/<some>-<some>-<some>.json

You should use a valid service account file. You can get this file from: https://console.cloud.google.com/apis/credentials?pli=1

Follow this simple steps: How can I get the file "service_account.json" for Google Translate API?

Then put in yml configuration

service_account_file: ~/service_account.json

or something similar

balucio
  • 124
  • 3
  • 6