iamckn / wireguard_ansible

Ansible scripts for the set up a typical wireguard VPN connection
https://www.ckn.io/blog/2017/11/14/wireguard-vpn-typical-setup/
322 stars 69 forks source link

Make this a role #5

Closed kjgd closed 5 years ago

kjgd commented 5 years ago

This should be formatted as a Role so that it can be incorporated into other playbooks, by

cd my_playbook/roles
git pull [wireguard_ansible repository url]

I have the major changes done (moving things into tasks/ etc, renaming wireguard.yml to main.yml, etc).

However the issue remains how to create a playbook.yml that can live in the wireguard_ansible directory:

#
# Unfinished: As written this file needs to be placed in ../../ and the
# current directory in ../roles/, so e.g
#   - ~/my_playbook/playbook.yml
#   - ~/my_playbook/roles/wireguard_ansible/
#
# There is probably a way to include the files directly without the
# `roles` directory structure, while maintaining the ability to use
# the current directory as a role:
#   https://docs.ansible.com/ansible/2.3/playbooks_roles.html
#
- name: Setup VPN
  hosts: all
  gather_facts: true
  roles:
    - {role: 'wireguard_ansible', tags: 'wireguard'}

I've made quite a lot of other minor fixes as well:

However, submitting pull requests for those is not practical unless we get the role-friendly directory structure solved, since my files have already been rearranged to fit the role structure.

(I also have to do some minor debugging and figure out why connections are not working, oops!)

iamckn commented 5 years ago

Let me look at the role structure this week then you can do a pull request for the other fixes. Thank you for the great suggestions and improvements!

iamckn commented 5 years ago

The project has been restructured as a role. The wireguard_role directory can easily be included in other playbooks.

The following have also been done:

For the other suggested fixes, you can submit a pull request as is necessary.