aboutsummaryrefslogtreecommitdiff
path: root/spec/acceptance/services.rb
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppet.com>2018-06-27 22:06:49 -0700
committerJosh Cooper <josh@puppet.com>2018-06-27 22:08:47 -0700
commit69f941224a43275896218807fd91c8e5b912f8d1 (patch)
tree06311b92c16f40868be7a106e3e831b6c97b7d51 /spec/acceptance/services.rb
parentc051e86b350329bc1a7cd1c9c239ec29212b8e56 (diff)
downloadpuppet-augeas_core-69f941224a43275896218807fd91c8e5b912f8d1.tar.gz
puppet-augeas_core-69f941224a43275896218807fd91c8e5b912f8d1.tar.bz2
Initial augeas import from puppet#2b83deb189
Diffstat (limited to 'spec/acceptance/services.rb')
-rw-r--r--spec/acceptance/services.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/acceptance/services.rb b/spec/acceptance/services.rb
new file mode 100644
index 0000000..ec87316
--- /dev/null
+++ b/spec/acceptance/services.rb
@@ -0,0 +1,73 @@
+test_name "Augeas services file" do
+
+ tag 'risk:medium',
+ 'audit:medium',
+ 'audit:acceptance',
+ 'audit:refactor' # move to types test dir
+ # use single manifest/apply
+
+ skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio'
+
+ confine :except, :platform => 'windows'
+ confine :except, :platform => 'osx'
+ confine :to, {}, hosts.select { |host| ! host[:roles].include?('master') }
+
+ step "Backup the services file" do
+ on hosts, "cp /etc/services /tmp/services.bak"
+ end
+
+ begin
+ step "Add an entry to the services file" do
+ manifest = <<EOF
+augeas { 'add_services_entry':
+ context => '/files/etc/services',
+ incl => '/etc/services',
+ lens => 'Services.lns',
+ changes => [
+ 'ins service-name after service-name[last()]',
+ 'set service-name[last()] "Doom"',
+ 'set service-name[. = "Doom"]/port "666"',
+ 'set service-name[. = "Doom"]/protocol "udp"'
+ ]
+}
+EOF
+
+ on hosts, puppet_apply('--verbose'), :stdin => manifest
+ on hosts, "fgrep 'Doom 666/udp' /etc/services"
+ end
+
+ step "Change the protocol to udp" do
+ manifest = <<EOF
+augeas { 'change_service_protocol':
+ context => '/files/etc/services',
+ incl => '/etc/services',
+ lens => 'Services.lns',
+ changes => [
+ 'set service-name[. = "Doom"]/protocol "tcp"'
+ ]
+}
+EOF
+
+ on hosts, puppet_apply('--verbose'), :stdin => manifest
+ on hosts, "fgrep 'Doom 666/tcp' /etc/services"
+ end
+
+ step "Remove the services entry" do
+ manifest = <<EOF
+augeas { 'del_service_entry':
+ context => '/files/etc/services',
+ incl => '/etc/services',
+ lens => 'Services.lns',
+ changes => [
+ 'rm service-name[. = "Doom"]'
+ ]
+}
+EOF
+
+ on hosts, puppet_apply('--verbose'), :stdin => manifest
+ on hosts, "fgrep 'Doom 666/tcp' /etc/services", :acceptable_exit_codes => [1]
+ end
+ ensure
+ on hosts, "mv /tmp/services.bak /etc/services"
+ end
+end