Skip to content

Commit

Permalink
fixing wireguars-show (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Feb 26, 2024
1 parent 02df843 commit 1013553
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
13 changes: 3 additions & 10 deletions docs/source/modules/wireguard.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ For basic parameters see: [Basics](https://opnsense.ansibleguy.net/en/latest/usa

### ansibleguy.opnsense.wireguard_show

| Parameter | Type | Required | Default value | Aliases | Comment |
|:------------|:--------|:---------|:--------------|:---------------------------------------------------------------------------------------------------|:--------------------------------------------------------|
| target | string | false | handshake | - | What information to query. One of: 'handshake', 'config' |
Will return the information seen at the `VPN - Wireguard - Diagnostics` page

### ansibleguy.opnsense.wireguard_general

Expand Down Expand Up @@ -107,16 +105,11 @@ To make a dynamic WireGuard endpoint to re-connect you may want to create a [gat
tasks:
- name: Example
ansibleguy.opnsense.wireguard_show:
# target: 'handshake'

- name: Querying the current WireGuard handshakes
ansibleguy.opnsense.wireguard_show:
target: 'handshake'
register: wg_hands
register: wg_status

- name: Printing
ansible.builtin.debug:
var: wg_hands.data
var: wg_status.data
```
### ansibleguy.opnsense.wireguard_peer
Expand Down
12 changes: 1 addition & 11 deletions plugins/modules/wireguard_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

def run_module():
module_args = dict(
target=dict(
type='str', required=False, default='handshake',
choices=['handshake', 'config'],
description='What information to query'
),
**OPN_MOD_ARGS,
)

Expand All @@ -37,17 +32,12 @@ def run_module():
supports_check_mode=True,
)

command_mapping = {
'config': 'showconf',
'handshake': 'showhandshake',
}

info = single_get(
module=module,
cnf={
'module': 'wireguard',
'controller': 'service',
'command': command_mapping[module.params['target']],
'command': 'show',
}
)

Expand Down
11 changes: 1 addition & 10 deletions tests/wireguard_show.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,9 @@
ssl_verify: false

tasks:
- name: Showing handshakes
- name: Showing config
ansibleguy.opnsense.wireguard_show:
target: 'handshake'
register: opn1
failed_when: >
opn1.failed or
'data' not in opn1
- name: Showing config
ansibleguy.opnsense.wireguard_show:
target: 'config'
register: opn2
failed_when: >
opn2.failed or
'data' not in opn2

0 comments on commit 1013553

Please sign in to comment.