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

(CLOUD-1560)-adding-functionality to remove systemd service files. #61

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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ If using Hiera, you can configure the `docker::run_instance` class:
command: '/bin/sh -c "while true; do echo hello world; sleep 1; done"'
```

To remove a running container, add the following code to the manifest file. This will also remove the systemd service file associated with the container.

'''puppet
docker::run { 'helloworld':
ensure => absent,
}
'''

### Networks

Docker 1.9.x officially supports networks. To expose the `docker_network` type, which is used to manage networks, add the following code to the manifest file:
Expand Down
4 changes: 4 additions & 0 deletions manifests/run.pp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@
timeout => 0
}

File { "/etc/systemd/system/${service_prefix}${sanitised_title}.service":
ensure => absent,
path => "/etc/systemd/system/${service_prefix}${sanitised_title}.service",
}
}
else {
file { $initscript:
Expand Down
1 change: 1 addition & 0 deletions spec/acceptance/docker_full_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class { 'docker':}
sleep 15

shell('docker inspect container-3-6', :acceptable_exit_codes => [1])
shell('test -f /etc/systemd/system/container-3-6.service', :acceptable_exit_codes => [1])
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/defines/run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@
it { should compile.with_all_deps }
it { should contain_service('docker-sample').with_ensure(false) }
it { should contain_exec("remove container docker-sample").with_command('docker rm -v sample') }
it { should_not contain_file('docker-sample.service')}
end

end
Expand Down