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

Adding ability to name your VPN config on import instead of having it… #86

Merged
merged 3 commits into from
Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ These attributes are set by the cookbook by default.
* `node['openvpn']['push_routes']` - Array of routes to to push to clients (as `push` statements) in the server.conf, e.g. '192.168.0.0 255.255.255.0'. Default is empty.
* `node['openvpn']['push_options']` - Array of options to to push to clients in the server.conf. Default is empty.
* `node['openvpn']['configure_default_server']` - Boolean. Set this to false if you want to create all of your "conf" files with the LWRP.
* `node['openvpn']['client_prefix'] - String. Name of the config that is created for clients. When imported into most vpn clients, this is the name that will be displayed for the connection. Default is 'vpn-prod'.
* `node['openvpn']['key_dir']` - Location to store keys, certificates and related files. Default `/etc/openvpn/keys`.
* `node['openvpn']['signing_ca_cert']` - CA certificate for signing, default `/etc/openvpn/keys/ca.crt`
* `node['openvpn']['signing_ca_key']` - CA key for signing, default `/etc/openvpn/keys/ca.key`
Expand Down
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
default['openvpn']['key']['message_digest'] = 'sha256'

# Cookbook attributes
default['openvpn']['client_prefix'] = 'vpn-prod'

This comment was marked as outdated.

default['openvpn']['key_dir'] = '/etc/openvpn/keys'
default['openvpn']['signing_ca_key'] = "#{node['openvpn']['key_dir']}/ca.key"
default['openvpn']['signing_ca_cert'] = "#{node['openvpn']['key_dir']}/ca.crt"
Expand Down
4 changes: 2 additions & 2 deletions recipes/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def chef_solo_search_installed?
end

%w(conf ovpn).each do |ext|
template "#{node['openvpn']['key_dir']}/#{u['id']}.#{ext}" do
template "#{node['openvpn']['key_dir']}/#{node['openvpn']['client_prefix']}-#{u['id']}.#{ext}" do
source 'client.conf.erb'
variables(client_cn: u['id'])
end
Expand All @@ -58,7 +58,7 @@ def chef_solo_search_installed?
execute "create-openvpn-tar-#{u['id']}" do
cwd node['openvpn']['key_dir']
command <<-EOH
tar zcf #{u['id']}.tar.gz ca.crt #{u['id']}.crt #{u['id']}.key #{u['id']}.conf #{u['id']}.ovpn
tar zcf #{u['id']}.tar.gz ca.crt #{u['id']}.crt #{u['id']}.key #{node['openvpn']['client_prefix']}-#{u['id']}.conf #{node['openvpn']['client_prefix']}-#{u['id']}.ovpn
EOH
not_if { ::File.exist?("#{node['openvpn']['key_dir']}/#{u['id']}.tar.gz") }
end
Expand Down