Giter Site home page Giter Site logo

puppet-git's Introduction

puppet-git

============

Build Status

A puppet module for managing the installation and configuration of git so that it is available by use by the Puppetlabs vcsrepo module. This includes installing, configuring and the installation of git, the configuration of git specific settings, executing git commands, and eventually the management of git hook scripts.

WARNING The use of this module to manage git repositories is being depreciated and will soon become obsolete. It is recommended that the Puppetlabs vcsrepo module is used manage repositories.

Implemented Features:

  • Installs git from packages
  • Optionally installs git-svn from packages (defaults installed)
  • Optionally installs git-gui from packages (defaults not installed)

Features not yet updated

  • Initialising user accounts with git configurations
  • Configure global and local git configurations
  • Executing git commands not provided by the Puppetlabs vcsrepo module.
  • Injecting hook scripts into git repositories.

Classes

git

This class installs and manages the git package.

A basic install with the defaults would be:

include git

Otherwise using the parametrs:

class{git:
  svn => 'installed',
  gui => 'installed',
}

Parameters

  • ensure: Sets the ensure parameter passed to the git package. The default is installed.
  • svn: Sets the ensure paramater passed to the git-svn package. The default is installed.
  • gui: Sets the ensure parameter passed to the git-gui package. The default is absent.
  • package: Specifies a custom package. The default is git, except for older versions of Debian and Ubuntu where the default is git-core.
  • git_root: Currently does nothing, it's functionality is to be reviewed.

Resources

git::user

This basically sets the users name and email by configuring the git global variables as that user, and should allow them to use git without warnings about these values being unset. The user name should be a valid user account that has been previously defined in Puppet.

With default settings just use:

git::user{'username':}

Otherwise using parameters:

git::user{'username':
 user_name  => 'Some User',
 user_email => '[email protected]',
}

Parameters

  • user_name sets the user's name to the specified string, and not the default of ${name} on ${fqdn}, where fqdn is the fully qualified domain name as discovered by facter.
  • user_email sets the user's email address to the specified string, and not the default of ${name}@${fqdn}, where fqdn is the fully qualified domain name as discovered by facter.

git::config

This resource allows puppet to manage git configurations at the system (setting defaults for all usage), global (setting defaults for all a user's repositories), and local (setting defaults for a repository). These contexts are represented by the provider parameter.

When setting a global config value a user is required:

git::config{'git_core_autocrlf':
  config   => 'core.autocrlf',
  value    => 'input',
  provider => 'global',
  user     => $user
}

When setting a local config value a vcsrepo repository is required:

git::config{'git_core_autocrlf':
  config   => 'core.autocrlf',
  value    => 'input',
  provider => 'local',
  repo     => 'reponame'
}

git::repo

Using the git::repo class is depreciated and vcsrepo should be considered instead.

This will clone a git repository from a vaild git URI to a specified path on the target server. It is strongly recommended that read-only git URIs are used. If no source is given, the target path will simply be initialised as a git repository.

With minimum parameters, should create the directory /usr/src/repo and run git init in it:

git::repo{'repo_name':
  path => '/usr/src/repo',
}

With minimum parameters to clone from a remote source:

git::repo{'repo_name':
 path   => '/usr/src/repo',
 source => 'git://example.org/example/repo.git'
}

Parameters

  • path sets the path where the git repository is created or cloned to
  • source sets the git URI from which the git repository is cloned from
  • branch this string sets a specific branch to check out
  • git_tag this string sets a specific tag to check out
  • update if set to true, when puppet runs it will revert any local changes and pull the current branch from the source if there is any difference between the local repository and the source repository.
  • bare if set to true, it creates a bare repository

Note: I am uncertain on how it will behave if both tag and branch are set, but tag should override branch.

Dependencies

Attribution

puppet-blank

This module is derived from the puppet-blank module by Aaron Hicks ([email protected])

This module has been developed for the use with Open Source Puppet (Apache 2.0 license) for automating server & service deployment.

Gnu General Public License

This file is part of the git Puppet module.

The git Puppet module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The git Puppet module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the git Puppet module. If not, see http://www.gnu.org/licenses/.

puppet-git's People

Contributors

aethylred avatar b4ldr avatar citec avatar coltonj avatar danfruehauf avatar dkapanidis avatar kaofelix avatar lancespeelmon avatar lchenay avatar macdabby avatar newloki avatar stvolodymyr avatar theospears avatar venefyxatu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

puppet-git's Issues

git_tag potentailly does not work

I am using the following puppet code:

class{git:
  svn => false,
  gui => false,
}

class cgit {
  git::repo{'cgit':
    path    => '/usr/local/src/cgit',
    source  => 'git://git.zx2c4.com/cgit',
    git_tag => 'v0.9.1',
  }

}

I am expecting this to clone the repo and check out the tag `v0.9.1`` But when
I go to check which version is actually checked out I see:

root@precise32:/usr/local/src/cgit# git describe
v0.9.1-88-g7966fd9

And not:

root@precise32:/usr/local/src/cgit# git describe
v0.9.1

Any ideas? Or is it an error on my part (am new to puppet).

Rename Class Git to something else

Hi,

We already have a module git that installs the client for linux and windows. Is it possible to rename the module to something different. Like "gitget or nesigit".

I guess i will have to do it manually for now..

git::repo -l flag in su cause issue

I ran in the following issue:

Notice: /Stage[main]/Main/Git::Repo[gitolite-admin]/Exec[git_gitolite-admin_co_branch]/returns: fatal: This operation must be run in a work tree
Error: /bin/su -l git -c "/usr/bin/git checkout master" returned 128 instead of one of [0]
Error: /Stage[main]/Main/Git::Repo[gitolite-admin]/Exec[git_gitolite-admin_co_branch]/returns: change from notrun to 0 failed: /bin/su -l git -c "/usr/bin/git checkout master" returned 128 instead of one of [0]

Caused by the following code:

git::repo { 'gitolite-admin':
  path    => "${gitolite3::params::gt_repo_base}/gitolite-admin",
  source  => "${gitolite3::params::gt_repo_dir}/gitolite-admin",
  owner   => $gitolite3::params::gt_uid,
  group   => $gitolite3::params::gt_gid,
  update  => true,
  branch  => master,
}

Removing the -l flag solves the issue.

Cannot alias Package[git] to ["git-core"]

I went to spool up a Vagrant box today that I built using PuPHPet (and tweaked a bit), and it returns the following error:

Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias Package[git] to ["git-core"] at /etc/puppet/modules/git/manifests/init.pp:54; resource ["Package", "git-core"] already declared at /etc/puppet/modules/git/manifests/init.pp:54 on node debian-70rc1-x64-vbox4210.vagrantup.com
Wrapped exception:
Cannot alias Package[git] to ["git-core"] at /etc/puppet/modules/git/manifests/init.pp:54; resource ["Package", "git-core"] already declared
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias Package[git] to ["git-core"] at /etc/puppet/modules/git/manifests/init.pp:54; resource ["Package", "git-core"] already declared at /etc/puppet/modules/git/manifests/init.pp:54 on node debian-70rc1-x64-vbox4210.vagrantup.com
No error message

My Puppetfile is (to the best of my knowledge) retrieving your Git module using mod 'git', :git => 'git://github.com/nesi/puppet-git.git', so I can only assume that your recent changes have somehow affected this. I haven't spooled up this box for a few days, and it has worked perfectly fine up until now.

Apologies if I'm wrong in my assumptions, and for providing little detail (I didn't want to paste every config file I have, since PuPHPet generates quite a few of them). If I can answer any questions or if you have any thoughts, I'd love to hear them. I'll continue investigating this myself when I have a spare moment, but for now, work beckons! :)

git::config define is not functional

my code:

$title = username
git::config { "set user.name for ${title}":
  value   => $git_user_name,
  config  => 'user.name',
  user    => $title,
  provider => 'global',
  require =>  [ User[$title], Group[$group] ],
}

produces error:

Error: /Stage[main]/users::Others/users::Add[perfilov]/Git::Config[set user.name for perfilov]/Exec[git_config_set user.name for perfilov]: Could not evaluate: Could not find command ''

centos 6.6
puppet-3.7.4-1.el6.noarch

Allow separate $title and $user for git::user

Currently can't alias git::user instances using the form:

git::user{'a_convenient_alias':
  $name => $some_var,
  $user_name => "Long Name",
  $user_email => "${some_var}@example.org",
}

`git::repo` does not update remote URL if it changes.

If you change a git::repo source parameter, e.g.

git::repo{'foo':
  path    => '/usr/src/foo,
  source  => 'git://github.com/me/foo.git',
}

to

git::repo{'foo':
  path    => '/usr/src/foo,
  source  => 'git://github.com/you/foo.git',
}

And does nothing.

While doing the same and changing the branch (iff the new branch does not exist on the old remote):

git::repo{'foo':
  path    => '/usr/src/foo,
  source  => 'git://github.com/me/foo.git',
  branch  => 'master',
}

to

git::repo{'foo':
  path    => '/usr/src/foo,
  source  => 'git://github.com/you/foo.git',
  branch  => 'baa',
}

results in the error:

Error: /usr/bin/git checkout baa returned 1 instead of one of [0]
Error: /Stage[main]/Puppetdashboard::Install/Git::Repo[puppet-dashboard]/Exec[git_puppet-dashboard_co_branch]/returns: change from notrun to 0 failed: /usr/bin/git checkout baa returned 1 instead of one of [0]

...well because the baa branch doesn't exist.

puppet-git doesn't appear to honor --noop

I just did a test run using --noop (I am running masterless puppet), and for some reason the git repo was still cloned.

I am using 2.6.12 which I admit is a little old.

/bin/su ${name} doesn't switch to user's environment

In user.pp, lines 36-44, the various su commands do not assume the target user's environment (at least on CentOS and RHEL). A hyphen after su solves this issue by spawning a shell.

example:

    command => "/bin/su ${name} -c '${git::params::bin} config --global user.name \"${git_name}\"'",

vs

    command => "/bin/su - ${name} -c '${git::params::bin} config --global user.name \"${git_name}\"'",

Consider supporting read/write git URLs

I notice in the readme it says this:

It is strongly recommended that read-only git URIs are used.

However, it doesn't explain why. We have a use case for doing read/write checkouts so users can contribute back to the projects.

Would you consider looking at a pull request for read/write URLs? If not, can you explain why in the readme?

Thanks much

$HOME not set on centos 6.3 vm

Having a problem installing a user with your plugin. It seems the user's environment is not setup. Any idea how to work around the problem?

Debug: Execjenkins_git_name: Executing check '/usr/bin/git config --global user.name|/bin/grep 'jenkins''

Debug: Executing '/usr/bin/git config --global user.name|/bin/grep 'jenkins''
Debug: /Stage[main]/Ops_ui/Git::User[jenkins]/Exec[jenkins_git_name]/unless: fatal: $HOME not set

Debug: Execjenkins_git_name: Executing '/usr/bin/git config --global user.name 'jenkins''

Debug: Executing '/usr/bin/git config --global user.name 'jenkins''

Notice: /Stage[main]/Ops_ui/Git::User[jenkins]/Exec[jenkins_git_name]/returns: fatal: $HOME not set

Error: /usr/bin/git config --global user.name 'jenkins' returned 128 instead of one of [0]

Error: /Stage[main]/Ops_ui/Git::User[jenkins]/Exec[jenkins_git_name]/returns: change from notrun to 0 failed: /usr/bin/git config --global user.name 'jenkins' returned 128 instead of one of [0]

Could not find dependency error

I'm trying to use puppet as my vagrant VM provision and use this module to clone a certain git repo and I keep getting this error:
Could not find dependency Exec[git_repo_hub] for Exec[git_hub_co_branch] at /tmp/vagrant-puppet/modules-0/git/manifests/repo.pp:81

With this in my manifest:

class { 'git':
  gui => false,
  svn => false,
}

git::repo { 'hub':
  path => '/home/vagrant/code/sandbox/hub',
  source => 'https://github.com/defunkt/hub.git',
}

Am I missing something here?

timeout variable

Hi, I would suggest to add the ability of passing timeout to repo cloning class, as it is set to 600 seconds now, hardcoded.

${target} should probably be ${path}

No patch, but in manifests/repo.pp lines 44-48

    if $bare {
      $init_cmd = "${git::params::bin} init --bare ${target}"
    } else {
      $init_cmd = "${git::params::bin} init ${target}"
    }

If ${target} is a magic variable or gets set elsewhere, I can't find it. I think ${path} is what is needed there but I'm not entirely sure.

git::install fails in Ubuntu 10.04

The package name apt needs is actually git-core here.

err: /Stage[main]/Git::Install/Package[git]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install git' returned 100: Reading package
 lists...
Building dependency tree...
Reading state information...
Package git is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package git has no installation candidate

git::config define error

include git
git::config { 'core.excludesfile':
    value    => "/opt/svn/tutu-tools/git/.gitignore",
    user     => 'root',
    provider => 'system',
}

produces error

Warning: Exec[git_config_core.excludesfile](provider=posix): Cannot understand environment setting "HOME="

git::config define error

include git
git::config { 'core.excludesfile':
    value    => "/opt/svn/tutu-tools/git/.gitignore",
    provider => 'system',
}

produces

Error: /usr/bin/git config --system core.excludesfile '/opt/svn/tutu-tools/git/.gitignore' returned 128 instead of one of [0]
Error: /Stage[main]/Git::Config[core.excludesfile]/Exec[git_config_core.excludesfile]/returns: change from notrun to 0 failed: /usr/bin/git config --system core.excludesfile '/opt/svn/tutu-tools/git/.gitignore' returned 128 instead of one of [0]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.