- name: Get existing users ansible.builtin.uri: url: https://{{ fwhost }}/api/wireguard/client/searchClient method: GET user: "{{ opnsense_key }}" password: "{{ opnsense_secret }}" force_basic_auth: true validate_certs: false return_content: false register: wg
curl -k -u {{ opnsense_key }}:{{ opnsense_secret }} https://{{ fwhost }}/api/wireguard/client/searchClient
- name: Create users ansible.builtin.uri: url: https://{{ fwhost }}/api/wireguard/client/addClient method: POST url_username: "{{ opnsense_key }}" url_password: "{{ opnsense_secret }}" force_basic_auth: true validate_certs: false return_content: true headers: Content-Type: application/json body_format: json body: enabled: true name: "{{ item.key }}" pubkey: "{{ keys }}" tunneladdress: "{{ item.value.tunneladdress }}" with_dict: - "{{ wireguard_users }}" register: result
curl -X POST -d '{"enabled”:"1",”name”:”test.user”,“pubkey“:“$key“,“tunneladdress“:“xxx.xxx.xxx.xxx/xx“}' -H "Content-Type: application/json" -k -u $key:$secret https://$IP/api/wireguard/client/addClient
curl -k -u "user":"pass" "https://opnsense/api/firewall/filter/toggleRule/702cdc85-cf43-437a-9882-4beba77fb35c/0" -X POST -d ""{"result":"failed"}%
url -k -u key:pass "https:/opnsense/api/firewall/filter/getRule?uuid=702cdc85-cf43-437a-9882-4beba77fb35c"
curl -k -u key:pass "https://opnsense/api/firewall/filter/toggleRule/702cdc85-cf43-437a-9882-4beba77fb35c/1"
When run the curl commandCode: [Select]curl -X POST -d '{"enabled”:"1",”name”:”test.user”,“pubkey“:“$key“,“tunneladdress“:“xxx.xxx.xxx.xxx/xx“}' -H "Content-Type: application/json" -k -u $key:$secret https://$IP/api/wireguard/client/addClientI get the same message {"result":"failed"}.There is nothing to find in any log files, so what am I doing wrong?Thank you in advance.
curl -X POST -d '{"client":{"enabled”:"1",”name”:”test.user”,“pubkey“:“$key“,“tunneladdress“:“xxx.xxx.xxx.xxx/xx“}}' -H "Content-Type: application/json" -k -u $key:$secret https://$IP/api/wireguard/client/addClient
QuoteWhen run the curl commandCode: [Select]curl -X POST -d '{"enabled”:"1",”name”:”test.user”,“pubkey“:“$key“,“tunneladdress“:“xxx.xxx.xxx.xxx/xx“}' -H "Content-Type: application/json" -k -u $key:$secret https://$IP/api/wireguard/client/addClientI get the same message {"result":"failed"}.There is nothing to find in any log files, so what am I doing wrong?Thank you in advance.I just hit this also; you need the following format:Code: [Select]curl -X POST -d '{"client":{"enabled”:"1",”name”:”test.user”,“pubkey“:“$key“,“tunneladdress“:“xxx.xxx.xxx.xxx/xx“}}' -H "Content-Type: application/json" -k -u $key:$secret https://$IP/api/wireguard/client/addClienti.e: Wrap your existing code in an outer {"client": ... }