Giter Club home page Giter Club logo

ansible-role-wireguard's Introduction

WireGuard Ansible role

Ansible role that configures WireGuard interfaces on Linux machines.

Requirements

None, but requires the ability to create WireGuard interfaces. This may not work on unprivileged Linux containers, but will work on bare metal and fully-virtualized virtual machines.

This role has been developed for use with Debian and Alpine Linux. Other distros may work and support may be added on a best-effort basis. Feel free to submit a pull request if you would like support to be added to other distributions.

Known issues

Currently, the role does not restart the WireGuard interface when changes are made. One must restart the interface using systemctl or rc-service manually after changing the interface.

Role Variables

  • wg_interfaces: List of interfaces managed by this role.
    • private_key: Private key used by the wg interface.
    • listen: Enable listening for connections on the interface. Defaults to false.
    • listen_port: If listen is true, the port to listen on. defaults to 51820.
    • addresses: List of IPv4 and IPv6 addresses.
    • started: Start the interface after creation
    • enabled: Enable the interface to start on boot
    • dns: DNS server to advertise to peers
    • post_up: Post-up commands
    • pre_down: Pre-down commands
    • post_down: Post-down commands
    • peers: List of peers
      • name: Name of the peer. Optional.
      • public_key: Peer public key
      • allowed_ips: IP addresses the peer can use
      • endpoint: If connecting to another peer that is listening, the endpoint to connect to. Optional.
      • persistent_keepalive: Enable persistent keepalive. Recommended for peers behind NAT.
  • wg_persistent_keepalive_time: For peers using persistent keepalive, set the seconds used for keepalive timers. Defaults to 30 seconds.
  • wg_sysctl: If set to true, the role will manage sysctls for IPv4 and IPv6 forwarding.
  • wg_sysctl_ipv4_fwd: Enable IPv4 forwarding
  • wg_sysctl_ipv6_fwd: Enable IPv6 forwarding

Default interface settings: see defaults/main.yml.

Dependencies

None.

Example playbook

NOTE: Interface settings should never be set in group_vars, only host_vars. Other settings, such as the default interface settings, may be configured using group_vars.

- host: peer1
  become: yes

  roles:
    - wireguard
  
  vars:
    wg_interfaces:
      - interface: wg0
        listen: true
        addresses:
          - 192.168.100.1/24
        private_key: peer1 private key
        started: true
        enabled: true
        peers:
          - name: peer2
            public_key: peer2 public key
            allowed_ips:
              - 192.168.100.2/32
              - 192.168.1.0/24 # adds a route for this network
            persistent_keepalive: true

License

MIT

Author

Colin Murphy [email protected]

ansible-role-wireguard's People

Contributors

colinmurphy1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.