Replies: 1 comment 1 reply
-
Greetings. You are right - when calling the As I see it - if your playbook does not known the 'whole truth', you might need to pull the existing peers beforehand and merge them with the one you want to add. On first though I would think of two ways of doing this:
- name: Listing
ansibleguy.opnsense.list:
target: 'wireguard_peer'
register: existing_entries
- name: Adding 3
ansibleguy.opnsense.wireguard_server:
...
peers: ['ANSIBLE_TEST_2_1']
register: wg_srv
check_mode: true
- debug:
var: wg_srv The output might look something like this: "wg_srv": {
"changed": true,
"diff": {
"before": {
...
"peers": [
"004bc7db-16ff-49b8-a566-3cf946f77482"
],
...
},
"after": {
...
}
},
...
}
``` |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I need to deploy multiple appliances which will be connected via wireguard to an opnsense. I need to create a peer and then add it to a specific server (instance). Currently I think that this is only possible when passing all peers to ansibleguy.opnsense.wireguard_server. But my staging playbook doesn't know which peers existing. As far as I know it is not possible to add or remove a peer from a server without the full peer-list. Am I missing something or does someone know a 'smart' way to archive this?
Regards
René
Beta Was this translation helpful? Give feedback.
All reactions