how to use the community.general.pritunl_user_info ansible module

112 views Asked by At

I'm working on automating Pritunl VPN housekeeping activities. I came across the community.general.pritunl_user_info module. I created a quick test playbook, below.

My question: I don't want to execute this playbook against a host (! think!), that's why I'm trying to use the local controller . The module is supposed to access the data via the api URL, using the token. How do I account for this in my playbook or tell the playbook not to use a "host"? I know I'm missing something here.

Thank you for any and all help, most appreciated!

- name: "pritunl test"
  hosts: localhost
  gather_facts: no
  connection: local
  become: no
  
  tasks:
  - name: "list pritunl users"
    community.general.pritunl_user_info:
     pritunl_url: https://xxxxx/
     pritunl_api_token: yyyyyy
     pritunl_api_secret: zzzzzz
     organization: xxyyzz

The above playbook gets skipped/fails during execution because it cannot connect to localhost. See below.

[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
redirecting (type: modules) community.general.pritunl_user_info to community.general.net_tools.pritunl.pritunl_user_info
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: pritunl_users.yml *****************************************************************************************************************************
1 plays in pritunl_users.yml

PLAY [pritunl test] *************************************************************************************************************************************
META: ran handlers

TASK [list pritunl users] *******************************************************************************************************************************
task path: /home/.../pritunl_users.yml:8
redirecting (type: modules) community.general.pritunl_user_info to community.general.net_tools.pritunl.pritunl_user_info
redirecting (type: modules) community.general.pritunl_user_info to community.general.net_tools.pritunl.pritunl_user_info
fatal: [localhost]: FAILED! => {"changed": false, "msg": "HTTP Error 404: Not Found"}

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

1

There are 1 answers

4
phani raj goutham On BEST ANSWER

I have copy pasted your script and plugged in the values and tested the script out. The script is working as expected.

I don't have a ssh server running on my machine, yet the script was running. So, your issue might not be related to SSH/connection to localhost as well.

I've was able to reproduce your error {"changed": false, "msg": "HTTP Error 404: Not Found"}, by changing the pritunl_url. Only when the pritunl_url value is different the issue happens. Please note that, even if you have a / in the end of pritunl_url the script was not working.

I've tried other combinations like, if the API_TOKEN, is wrong, the we are getting a 401, if the org name has a typo, it would show the correct error etc. So most probably your issue lies in the pritunl_url. Thanks.