summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.markdown197
-rw-r--r--lib/puppet/type/vcsrepo.rb14
-rw-r--r--metadata.json6
-rw-r--r--spec/acceptance/clone_repo_spec.rb40
-rw-r--r--spec/unit/puppet/provider/vcsrepo/git_spec.rb22
5 files changed, 161 insertions, 118 deletions
diff --git a/README.markdown b/README.markdown
index 99c5ac9..a8575a6 100644
--- a/README.markdown
+++ b/README.markdown
@@ -53,12 +53,104 @@ To get started with the vcsrepo module, you must simply define the type `vcsrepo
The vcsrepo module works with the following VCSs:
+* [Git (git)](#git)*
* [Bazaar (bzr)](#bazaar)
* [CVS (cvs)](#cvs)
-* [Git (git)](#git)
* [Mercurial (hg)](#mercurial)
* [Subversion (svn)](#subversion)
+**Note:* Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
+
+
+###Git
+
+#####To create a blank repository
+
+To create a blank repository suitable for use as a central repository,
+define `vcsrepo` without `source` or `revision`.
+
+ vcsrepo { "/path/to/repo":
+ ensure => present,
+ provider => git,
+ }
+
+If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'.
+
+ vcsrepo { "/path/to/repo":
+ ensure => bare,
+ provider => git,
+ }
+
+#####To clone/pull a repository
+
+To get the current HEAD on the master branch,
+
+ vcsrepo { "/path/to/repo":
+ ensure => present,
+ provider => git,
+ source => "git://example.com/repo.git",
+ }
+
+To get a specific revision or branch (can be a commit SHA, tag, or branch name),
+
+ **SHA**
+
+ vcsrepo { "/path/to/repo":
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
+ }
+
+**Tag**
+
+ vcsrepo { "/path/to/repo":
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => '1.1.2rc1',
+ }
+
+**Branch name**
+
+ vcsrepo { "/path/to/repo":
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => 'development',
+ }
+
+To check out a branch as a specific user,
+
+ vcsrepo { "/path/to/repo":
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
+ user => 'someUser',
+ }
+
+To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository),
+
+ vcsrepo { "/path/to/repo":
+ ensure => latest,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => 'master',
+ }
+
+#####Sources that use SSH
+
+When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
+
+For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys.
+
+ user => 'toto' # will use toto's $HOME/.ssh setup
+
+#####Further Examples
+
+For more examples using Git, see `examples/git/`.
+
###Bazaar
#####Create a blank repository
@@ -159,95 +251,6 @@ When your source uses SSH, you can manage your SSH keys with Puppet using the [r
For for more examples using CVS, see `examples/cvs/`.
-###Git
-
-#####To create a blank repository
-
-To create a blank repository suitable for use as a central repository,
-define `vcsrepo` without `source` or `revision`.
-
- vcsrepo { "/path/to/repo":
- ensure => present,
- provider => git,
- }
-
-If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'.
-
- vcsrepo { "/path/to/repo":
- ensure => bare,
- provider => git,
- }
-
-#####To clone/pull a repository
-
-To get the current HEAD on the master branch,
-
- vcsrepo { "/path/to/repo":
- ensure => present,
- provider => git,
- source => "git://example.com/repo.git",
- }
-
-To get a specific revision or branch (can be a commit SHA, tag, or branch name),
-
- **SHA**
-
- vcsrepo { "/path/to/repo":
- ensure => present,
- provider => git,
- source => 'git://example.com/repo.git',
- revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
- }
-
-**Tag**
-
- vcsrepo { "/path/to/repo":
- ensure => present,
- provider => git,
- source => 'git://example.com/repo.git',
- revision => '1.1.2rc1',
- }
-
-**Branch name**
-
- vcsrepo { "/path/to/repo":
- ensure => present,
- provider => git,
- source => 'git://example.com/repo.git',
- revision => 'development',
- }
-
-To check out a branch as a specific user,
-
- vcsrepo { "/path/to/repo":
- ensure => present,
- provider => git,
- source => 'git://example.com/repo.git',
- revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
- user => 'someUser',
- }
-
-To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository),
-
- vcsrepo { "/path/to/repo":
- ensure => latest,
- provider => git,
- source => 'git://example.com/repo.git',
- revision => 'master',
- }
-
-#####Sources that use SSH
-
-When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
-
-For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys.
-
- user => 'toto' # will use toto's $HOME/.ssh setup
-
-#####Further Examples
-
-For more examples using Git, see `examples/git/`.
-
###Mercurial
#####To create a blank repository
@@ -384,10 +387,10 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers
**Note**: Not all features are available with all providers.
+* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
* `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.)
* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.)
* `dummy` -
-* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
* `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.)
* `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.)
@@ -433,6 +436,11 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers
####Features and Parameters by Provider
+#####`git`
+**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`
+
+**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`
+
#####`bzr`
**Features**: `reference_tracking`
@@ -443,11 +451,6 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers
**Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user`
-#####`git`
-**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`
-
-**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`
-
#####`hg`
**Features**: `reference_tracking`, `ssh_identity`, `user`
@@ -460,6 +463,8 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers
##Limitations
+Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
+
This module has been built on and tested against Puppet 2.7 and higher.
The module has been tested on:
diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb
index 0e4450b..42767ab 100644
--- a/lib/puppet/type/vcsrepo.rb
+++ b/lib/puppet/type/vcsrepo.rb
@@ -98,9 +98,8 @@ Puppet::Type.newtype(:vcsrepo) do
if prov
if prov.working_copy_exists?
if @resource.value(:force)
- if noop?
- notice "Noop Mode - Would have deleted repository"
- notice "Noop Mode - Would have created repository from latest"
+ if noop
+ notice "Noop Mode - Would have deleted repository and re-created from latest"
else
notice "Deleting current repository before recloning"
prov.destroy
@@ -212,13 +211,4 @@ Puppet::Type.newtype(:vcsrepo) do
autorequire(:package) do
['git', 'git-core']
end
-
- def noop?
- if defined?(@noop)
- @noop
- else
- Puppet[:noop]
- end
- end
-
end
diff --git a/metadata.json b/metadata.json
index 22d3443..4772445 100644
--- a/metadata.json
+++ b/metadata.json
@@ -40,6 +40,12 @@
]
},
{
+ "operatingsystem": "SLES",
+ "operatingsystemrelease": [
+ "11 SP1"
+ ]
+ },
+ {
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb
index a989661..c52a5d2 100644
--- a/spec/acceptance/clone_repo_spec.rb
+++ b/spec/acceptance/clone_repo_spec.rb
@@ -318,6 +318,36 @@ describe 'clones a remote repo' do
describe file("#{tmpdir}/testrepo_force/.git") do
it { should be_directory }
end
+
+ context 'and noop' do
+ let(:repo_name) do
+ 'testrepo_already_exists'
+ end
+ before(:all) do
+ shell("mkdir #{tmpdir}/#{repo_name}")
+ shell("cd #{tmpdir}/#{repo_name} && git init")
+ shell("cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'")
+ end
+ after(:all) do
+ shell("rm -rf #{tmpdir}/#{repo_name}")
+ end
+
+ it 'applies the manifest' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ force => true,
+ noop => true,
+ }
+ EOS
+
+ apply_manifest(pp, :catch_changes => true) do |r|
+ expect(r.stdout).to match(/Noop Mode/)
+ end
+ end
+ end
end
context 'as a user' do
@@ -474,15 +504,5 @@ describe 'clones a remote repo' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
-
- after(:all) do
- pp = <<-EOS
- user { 'testuser-ssh':
- ensure => absent,
- managehome => true,
- }
- EOS
- apply_manifest(pp, :catch_failures => true)
- end
end
end
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
index a753610..2fd63f0 100644
--- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
@@ -175,6 +175,28 @@ branches
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.create
end
+ it "should warn about destroying it using force and noop attribute" do
+ resource[:force] = true
+ resource[:noop] = true
+ resource.delete(:revision)
+ provider.expects(:working_copy_exists?).returns(true)
+
+ provider.expects(:destroy).never
+ provider.expects(:create).never
+ Puppet::Type::Vcsrepo::Ensure.any_instance.expects(:send_log).with(:notice, "Noop Mode - Would have deleted repository and re-created from latest")
+ provider.resource.retrieve
+ end
+ it "should warn about destroying it using force and global noop" do
+ resource[:force] = true
+ Puppet[:noop] = true
+ resource.delete(:revision)
+ provider.expects(:working_copy_exists?).returns(true)
+
+ provider.expects(:destroy).never
+ provider.expects(:create).never
+ Puppet::Type::Vcsrepo::Ensure.any_instance.expects(:send_log).with(:notice, "Noop Mode - Would have deleted repository and re-created from latest")
+ provider.resource.retrieve
+ end
end
context "when the path is not empty and not a repository" do