Skip to content
This repository has been archived by the owner on Jun 25, 2023. It is now read-only.

Commit

Permalink
Issue #297 Adding capabilties to manage dnsmasq on Arch
Browse files Browse the repository at this point in the history
  • Loading branch information
njam authored and hferentschik committed Dec 8, 2016
1 parent 5601c90 commit 1077e14
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/landrush/cap/host/arch/dnsmasq_installed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Landrush
module Cap
module Arch
module DnsmasqInstalled
def self.dnsmasq_installed(_env, *_args)
system('pacman -Q dnsmasq > /dev/null 2>&1')
end
end
end
end
end
16 changes: 16 additions & 0 deletions lib/landrush/cap/host/arch/install_dnsmasq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Landrush
module Cap
module Arch
module InstallDnsmasq
class << self
def install_dnsmasq(_env)
system('pacman -Sy --noconfirm > /dev/null 2>&1')
system('sudo pacman -S --noconfirm dnsmasq > /dev/null 2>&1')

system('sudo sed -i "/^#conf-dir=\/etc\/dnsmasq.d$/s/^#//g" /etc/dnsmasq.conf')
end
end
end
end
end
end
21 changes: 21 additions & 0 deletions lib/landrush/cap/host/arch/restart_dnsmasq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Landrush
module Cap
module Arch
module RestartDnsmasq
class << self
SED_COMMAND = <<-EOF.gsub(/^ +/, '')
sudo sed -i.orig '1 i\
# Added by landrush, a vagrant plugin \\
nameserver 127.0.0.1 \\
' /etc/resolv.conf
EOF

def restart_dnsmasq(_env)
system(SED_COMMAND) unless system("cat /etc/resolv.conf | grep 'nameserver 127.0.0.1' > /dev/null 2>&1")
system('sudo systemctl restart dnsmasq')
end
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def configure_visibility_on_host(env, ip, tld)
env.host.capability(:create_dnsmasq_config, ip, tld)
env.host.capability(:restart_dnsmasq)
rescue Vagrant::Errors::CapabilityNotFound => e
env.ui.info("Your host was detected as '#{e.extra_data[:cap]}' for which the host capability " \
env.ui.info("Your host was detected as '#{e.extra_data[:host]}' for which the host capability " \
"'#{e.extra_data[:cap]}' is not available.")
env.ui.info('Check the documentation for the manual instructions to configure the visibility on the host.')
end
Expand Down
15 changes: 15 additions & 0 deletions lib/landrush/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,20 @@ def self.post_boot_actions
require_relative 'cap/host/suse/restart_dnsmasq'
Cap::Suse::RestartDnsmasq
end

host_capability('arch', 'dnsmasq_installed') do
require_relative 'cap/host/arch/dnsmasq_installed'
Cap::Arch::DnsmasqInstalled
end

host_capability('arch', 'install_dnsmasq') do
require_relative 'cap/host/arch/install_dnsmasq'
Cap::Arch::InstallDnsmasq
end

host_capability('arch', 'restart_dnsmasq') do
require_relative 'cap/host/arch/restart_dnsmasq'
Cap::Arch::RestartDnsmasq
end
end
end

0 comments on commit 1077e14

Please sign in to comment.