Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added apt_repository LWRP for adding and removing repositories to /et…
…c/apt/sources.list.d/ (cherry picked from commit 708fcd2f246c5f80316539d65df288313ff840f5)
- Loading branch information
Showing
3 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
action :add do | ||
Chef::Log.info "Adding #{new_resource.repo_name} repository to /etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" | ||
#build our listing | ||
repository = "deb" | ||
repository = "deb-src" if new_resource.deb_src | ||
repository = "#Created by the Chef apt_repository LWRP\n" + repository | ||
repository += " #{new_resource.uri}" | ||
repository += " #{new_resource.distribution}" | ||
new_resource.components.each {|component| repository += " #{component}"} | ||
#write out the file, replace it if it already exists | ||
file "/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" do | ||
owner "root" | ||
group "root" | ||
mode 0644 | ||
content repository + "\n" | ||
action :create | ||
end | ||
end | ||
|
||
action :remove do | ||
Chef::Log.info "Removing #{new_resource.repo_name} repository from /etc/apt/sources.list.d/" | ||
file "/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" do | ||
action :delete | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
actions :add, :remove | ||
|
||
#name of the repo, used for source.list filename | ||
attribute :repo_name, :kind_of => String, :name_attribute => true | ||
attribute :uri, :kind_of => String | ||
#whether or not to add the repository as a source repo as well | ||
attribute :deb_src, :default => false | ||
attribute :distribution, :kind_of => String | ||
attribute :components, :kind_of => Array, :default => [] |