Ansible Google Pubsub

32 views
Skip to first unread message

Yantram Cloud

unread,
Sep 9, 2020, 11:55:27 PM9/9/20
to ansible...@googlegroups.com
I am trying to create a subscription for google pubsub through ansible playbook.
 this is my task.
- name: create a subscription
  gcpubsub:
topic: test-topic1
state: present
credentials_file: "{{ gcp_cred_file }}"
project_id: "{{ gcp_project }}"

Now it does not seem to work,i have installed google-cloud-pubsub
getting this error regarding client.
Any help how can i debug this?
Here is the error.
The full traceback is:
Traceback (most recent call last):
  File "/home/rashmi/.ansible/tmp/ansible-tmp-1599709674.061256-7651-29288875173708/AnsiballZ_gcpubsub.py", line 102, in <module>
    _ansiballz_main()
  File "/home/rashmi/.ansible/tmp/ansible-tmp-1599709674.061256-7651-29288875173708/AnsiballZ_gcpubsub.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/rashmi/.ansible/tmp/ansible-tmp-1599709674.061256-7651-29288875173708/AnsiballZ_gcpubsub.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.cloud.google.gcpubsub', init_globals=None, run_name='__main__', alter_sys=True)
  File "/home/rashmi/anaconda3/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/home/rashmi/anaconda3/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/rashmi/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_gcpubsub_payload_soisvl0x/ansible_gcpubsub_payload.zip/ansible/modules/cloud/google/gcpubsub.py", line 333, in <module>
  File "/tmp/ansible_gcpubsub_payload_soisvl0x/ansible_gcpubsub_payload.zip/ansible/modules/cloud/google/gcpubsub.py", line 265, in main
AttributeError: module 'google.cloud.pubsub' has no attribute 'Client'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/rashmi/.ansible/tmp/ansible-tmp-1599709674.061256-7651-29288875173708/AnsiballZ_gcpubsub.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/rashmi/.ansible/tmp/ansible-tmp-1599709674.061256-7651-29288875173708/AnsiballZ_gcpubsub.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/rashmi/.ansible/tmp/ansible-tmp-1599709674.061256-7651-29288875173708/AnsiballZ_gcpubsub.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.cloud.google.gcpubsub', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/home/rashmi/anaconda3/lib/python3.7/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/home/rashmi/anaconda3/lib/python3.7/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/home/rashmi/anaconda3/lib/python3.7/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_gcpubsub_payload_soisvl0x/ansible_gcpubsub_payload.zip/ansible/modules/cloud/google/gcpubsub.py\", line 333, in <module>\n  File \"/tmp/ansible_gcpubsub_payload_soisvl0x/ansible_gcpubsub_payload.zip/ansible/modules/cloud/google/gcpubsub.py\", line 265, in main\nAttributeError: module 'google.cloud.pubsub' has no attribute 'Client'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

PLAY RECAP ********************************************************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  

Thanks



Dick Visser

unread,
Sep 10, 2020, 2:17:04 AM9/10/20
to ansible...@googlegroups.com
ansible --version

What does the entire playbook look like?


--


You received this message because you are subscribed to the Google Groups "Ansible Project" group.


To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ4U50WrcdL4OHQCi5OqunFDYK_b%2B%2B71e4dcQpgrnTexjDiFTw%40mail.gmail.com.


--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Yantram Cloud

unread,
Sep 10, 2020, 4:59:44 AM9/10/20
to Ansible Project


We are writing a playbook with ansible gcp_pubsub follwoing this.

https://docs.ansible.com/ansible/2.3/gcpubsub_module.html#requirements-on-host-that-executes-module
It errors out even in creating topic.

"gcp_pubsub.yml" 

- name: create a topic [ gcpubsub ]
  gcpubsub:
    topic: "{{ topic_name }}"
    state: present
    project_id: "{{ gcp_project }}"
    credentials_file: "{{ gcp_cred_file }}"

- name: create subscription[ gcpubsub ]
  gcpubsub:
    topic: "{{ topic_name }}"
    subscription:
      name: "{{ subscription_name }}"
    state: present
    project_id: "{{ gcp_project }}"
    credentials_file: "{{ gcp_cred_file }}"
       

Just for info , 
However when i use gcp_pubsub_topic to create topic and gcp_pubsub_subscription to create subscription , it works. but this is limited only to these.


Thanks,


Dick Visser

unread,
Sep 10, 2020, 9:26:08 AM9/10/20
to ansible...@googlegroups.com
I meant:

1. what version of ansible are you using (ansible --version)
2. what versions of google-auth and google-cloud-pubsub are you using (pip list)


The docs link you send is about ansible 2.3 which is ancient by now -
not sure if you intended this though.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1bfa4768-1dd1-4cc2-8c9d-a0f613304fdfn%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Yantram Cloud

unread,
Sep 10, 2020, 10:27:26 AM9/10/20
to Ansible Project
Yes, i think it seems to be very old, 

ansible 2.9.12

Name: google-cloud-pubsub
Version: 1.7.0

Name: google-auth
Version: 1.21.1



Reply all
Reply to author
Forward
0 new messages