br0ziliy / ansible-module-gce-facts Goto Github PK
View Code? Open in Web Editor NEWAnsible module to gather Google Cloud instance metadata and return it as facts
License: GNU General Public License v3.0
Ansible module to gather Google Cloud instance metadata and return it as facts
License: GNU General Public License v3.0
Is this module still alive?
Ansible 2.5 gets the following error:
"module_stdout": "Traceback (most recent call last):\r\n File "/tmp/ansible_m4gyRe/ansible_module_gce_facts.py", line 105, in \r\n main()\r\n File "/tmp/ansible_m4gyRe/ansible_module_gce_facts.py", line 96, in main\r\n gce_facts = GceMetadata(module).run()\r\n File "/tmp/ansible_m4gyRe/ansible_module_gce_facts.py", line 85, in run\r\n data = self._mangle_data(self._data)\r\n File "/tmp/ansible_m4gyRe/ansible_module_gce_facts.py", line 77, in _mangle_data\r\n ssh_keys = data['ansible_gce']['project']['attributes']['sshKeys']\r\nKeyError: 'sshKeys'\r\n",
"msg": "MODULE FAILURE",
"rc": 0
There is currently no license specified so this project defaults to full copyright by owner. In order to make it possible for others to use your work please consider specifying which license you would like this to be governed by.
Thank you for your work on this!
I get an error when I try to get the value of custom metadata attribute with an underscore in the key name. underscores work fine. Example below:
Excerpt from gce_facts output:
"ansible_facts": {
"ansible_gce": {
"instance": {
"attributes": {
"my-customkey2": "my-customvalue2",
"my_customkey1": "my_customvalue1",
"my_customkey3": "my_customvalue3",
"serial-port-enable": "true",
},
playbook:
- debug:
msg: "{{ ansible_gce.instance.attributes.my_customkey1 }}"
- debug:
msg: "{{ ansible_gce.instance.attributes.my_customkey3 }}"
- debug:
msg: "{{ ansible_gce.instance.attributes.my-customkey2 }}"
Error I receive when I run the playbook:
TASK [gce_labels : debug] *****************************************************************************************************************************************************************************************
ok: [hostname.example.com] => {
"msg": "my_customvalue1"
}
TASK [gce_labels : debug] *****************************************************************************************************************************************************************************************
ok: [hostname.example.com] => {
"msg": "my_customvalue3"
}
TASK [gce_labels : debug] *****************************************************************************************************************************************************************************************
fatal: [hostname.example.com]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: Unable to look up a name or access an attribute in template string ({{ ansible_gce.instance.attributes.my-customkey2 }}).\nMake sure your variable name does not contain invalid characters like '-': unsupported operand type(s) for -: 'StrictUndefined' and 'StrictUndefined'\n\nThe error appears to have been in '/etc/ansible/roles/gce_labels/tasks/main.yml': line 22, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n msg: \"{{ ansible_gce.instance.attributes.my_customkey3 }}\"\n- debug:\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: Unable to look up a name or access an attribute in template string ({{ ansible_gce.instance.attributes.my-customkey2 }}).\nMake sure your variable name does not contain invalid characters like '-': unsupported operand type(s) for -: 'StrictUndefined' and 'StrictUndefined'"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.