Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nmcli: honor IP options for VPNs #5228

Merged
merged 2 commits into from
Sep 8, 2022
Merged

nmcli: honor IP options for VPNs #5228

merged 2 commits into from
Sep 8, 2022

Conversation

yan12125
Copy link
Contributor

@yan12125 yan12125 commented Sep 4, 2022

SUMMARY

This can be used for split tunneling - I extended a test as an example.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

nmcli

ADDITIONAL INFORMATION

Here is a complete example. gw4_ignore_auto is used as VPNs often come with a default route for 0.0.0.0/0.

- name: >-
    Create a VPN L2TP connection for ansible_user to connect on vpn.example.com
    authenticating with user 'brittany' and pre-shared key as 'Brittany123'. Split tunneling
    is configured and only traffic to 192.168.200.0/24 goes throught the VPN.
  community.general.nmcli:
    type: vpn
    conn_name: my-vpn-connection
    vpn:
        permissions: "{{ ansible_user }}"
        service-type: org.freedesktop.NetworkManager.l2tp
        gateway: vpn.example.com
        password-flags: 2
        user: brittany
        ipsec-enabled: true
        ipsec-psk: "0s{{ 'Brittany123' | ansible.builtin.b64encode }}"
        gw4_ignore_auto: true
        routes4: '192.168.200.0/24'
    autoconnect: false
    state: present

This example is based on an existing example. I'm not sure if it's a good idea to include such a complex usage in examples.

- name: >-
Create a VPN L2TP connection for ansible_user to connect on vpn.example.com
authenticating with user 'brittany' and pre-shared key as 'Brittany123'
community.general.nmcli:
type: vpn
conn_name: my-vpn-connection
vpn:
permissions: "{{ ansible_user }}"
service-type: org.freedesktop.NetworkManager.l2tp
gateway: vpn.example.com
password-flags: 2
user: brittany
ipsec-enabled: true
ipsec-psk: "0s{{ 'Brittany123' | ansible.builtin.b64encode }}"
autoconnect: false
state: present

This can be used for split tunneling - I extended a test as an example.
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request module module net_tools plugins plugin (any type) tests tests unit tests/unit labels Sep 4, 2022
@felixfontein felixfontein added needs_backport_to_stable_1 check-before-release PR will be looked at again shortly before release and merged if possible. and removed needs_backport_to_stable_1 labels Sep 4, 2022
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Will keep this open for some more days so others can comment on this as well.

@felixfontein felixfontein merged commit 946c48d into ansible-collections:main Sep 8, 2022
@patchback
Copy link

patchback bot commented Sep 8, 2022

Backport to stable-5: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-5/946c48d14874f92cff38afb17ad276af2e05294d/pr-5228

Backported as #5252

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Sep 8, 2022
@felixfontein
Copy link
Collaborator

@yan12125 thanks for fixing this!

patchback bot pushed a commit that referenced this pull request Sep 8, 2022
* nmcli: honor IP options for VPNs

This can be used for split tunneling - I extended a test as an example.

* Add changelog

(cherry picked from commit 946c48d)
felixfontein pushed a commit that referenced this pull request Sep 8, 2022
* nmcli: honor IP options for VPNs

This can be used for split tunneling - I extended a test as an example.

* Add changelog

(cherry picked from commit 946c48d)

Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
@yan12125 yan12125 deleted the nmcli-ip-options branch September 8, 2022 08:14
@yan12125
Copy link
Contributor Author

yan12125 commented Sep 8, 2022

Glad to help :)

bratwurzt pushed a commit to bratwurzt/community.general that referenced this pull request Nov 7, 2022
* nmcli: honor IP options for VPNs

This can be used for split tunneling - I extended a test as an example.

* Add changelog
bratwurzt pushed a commit to bratwurzt/community.general that referenced this pull request Nov 7, 2022
* nmcli: honor IP options for VPNs

This can be used for split tunneling - I extended a test as an example.

* Add changelog
This was referenced Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request module module net_tools plugins plugin (any type) tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants