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

Unbreak vagrant #422

Merged
merged 5 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,47 @@ Installation, configuration and starting the OpenVPN client in a configured node
}
```

## Experimenting and developing in Vagrant

This project includes a Vagrantfile which allows you to easily develop this
module or try it out. The prerequisites are [Vagrant](https://www.vagrantup.com/)
and [VirtualBox](https://www.virtualbox.org/).

To bring up the OpenVPN server VM:

vagrant up server_ubuntu

To bring up the OpenVPN client VM:

vagrant up client_ubuntu

Client's OpenVPN configuration is generated on the server, but it needs to be
deployed to the client manually as exported resources are not available in
Vagrant. To get the client config from server:

vagrant ssh server_ubuntu
sudo -i
cp /etc/openvpn/winterthur/download-configs/client1.ovpn /vagrant/
exit

To copy it to the client:

vagrant ssh client_ubuntu
sudo -i
mv /vagrant/client1.ovpn /etc/openvpn/client/client1.conf

To connect directly with OpenVPN:

openvpn --config /etc/openvpn/client/client1.conf

To connect with systemd:

systemctl start openvpn-client@client1

To test connectivity between client and server:

ping 10.200.200.1

##### References

* The readme file of [github.com/Angristan/OpenVPN-install](https://github.com/Angristan/OpenVPN-install/tree/f47fc795d5e2d53f74431aadc58ef9de5784103a) outlines some of reasoning behind
Expand Down
8 changes: 4 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Vagrant::Config.run(2) do |config|

config.vm.define :server_ubuntu do |c|
c.vm.hostname = 'server'
c.vm.box = 'ubuntu/trusty64'
c.vm.box = 'ubuntu/focal64'
server_config c
c.vm.network :private_network, ip: '10.255.255.10'
c.vm.network :private_network, ip: '192.168.61.10'
end

config.vm.define :client_ubuntu do |c|
c.vm.hostname = 'client'
c.vm.box = 'ubuntu/trusty64'
c.vm.box = 'ubuntu/focal64'
client_config c
c.vm.network :private_network, ip: '10.255.255.20'
c.vm.network :private_network, ip: '192.168.61.20'
end
end
9 changes: 7 additions & 2 deletions vagrant/provision_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
set -e

if [ ! -f /module-installed ]; then
wget https://apt.puppet.com/puppet7-release-focal.deb
dpkg -i puppet7-release-focal.deb

apt-get update
apt-get install -y ruby-dev git
apt-get install -y ruby-dev git puppet-agent

export PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin

gem install librarian-puppet --no-rdoc --no-ri
gem install librarian-puppet --no-document

cp /vagrant/vagrant/Puppetfile /tmp
cd /tmp && librarian-puppet install --verbose
Expand Down
12 changes: 8 additions & 4 deletions vagrant/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
city => 'Winterthur',
organization => 'example.org',
email => '[email protected]',
local => '192.168.61.10',
server => '10.200.200.0 255.255.255.0',
}

openvpn::client { 'client1':
server => 'winterthur';
server => 'winterthur',
remote_host => '192.168.61.10',
}

openvpn::client_specific_config { 'client1':
Expand All @@ -18,14 +20,16 @@
}

openvpn::client { 'client2':
server => 'winterthur';
server => 'winterthur',
remote_host => '192.168.61.10',
}

openvpn::client { 'client3':
server => 'winterthur';
server => 'winterthur',
remote_host => '192.168.61.10',
}

openvpn::revoke { 'client3':
server => 'winterthur';
server => 'winterthur',
}
}