深入理解OpenStack自动化部署
  • 前言
  • 初识PuppetOpenstack
    • 相关约定
    • 术语表
    • PuppetOpenstack项目简介
  • Puppet开发基础
    • 关于Puppet
    • Puppet核心概念
    • 理解Hiera
    • 准备开发测试环境
  • OpenStack基础服务模块
    • puppet-apache模块
    • puppet-memcached模块
    • puppet-sysctl模块
    • puppet-rsync模块
    • puppet-xinetd模块
    • puppet-rabbitmq模块
    • puppet-firewall模块
    • puppet-mysql模块
    • puppet-vcsrepo模块
    • puppet-mongodb模块
    • puppet-ceph
  • Openstack服务模块
    • OpenStack模块代码结构
    • puppet-keystone模块
    • puppet-nova
    • puppet-neutron
    • puppet-glance
    • puppet-horizon
    • puppet-ceilometer
    • puppet-cinder
    • puppet-tempest
    • puppet-heat
    • puppet-swift
    • puppet-trove
    • puppet-sahara
    • puppet-manila
    • puppet-rally
    • puppet-designate
    • puppet-aodh模块
  • PuppetOpenstack公共库和工具类模块
    • puppet-oslo
    • puppet-vswitch模块
    • puppet-openstacklib
    • puppet-openstack-integration
    • puppet-openstack-specs
    • puppet-openstack-cookiebutter
    • puppet-modulesync-configs
    • puppet-openstack_spec_helper
    • puppet-stdlib
    • puppet-openstack_extras
  • 最佳实践
    • 模块管理
    • Hiera
    • 提交规范
    • 正确使用环境
    • 转发层规范
    • 代码风格
    • Standalone vs C\/S 模式
    • Puppet版本的选择
    • Puppet4的新特性和变化
    • Puppet的能与不能
  • 其他部署工具
    • Fuel
    • Kolla
    • TripleO
    • Packstack
    • OSA
    • DevStack
    • 编写一个定制化部署工具
  • 结语
Powered by GitBook
On this page
  • 1.先睹为快
  • 2.使用示例
  • 2.1 Git支持的特性和参数
  • 3.动手练习

Was this helpful?

  1. OpenStack基础服务模块

puppet-vcsrepo模块

Previouspuppet-mysql模块Nextpuppet-mongodb模块

Last updated 6 years ago

Was this helpful?

puppet-vcsrepo是由Puppet公司维护的官方模块,提供了管理版本控制系统(VCS)的能力,如:git,svn,cvs,bazaar等。 puppet-vcsrepo项目地址:

注1 vcsrepo并不会主动安装任何的vcs软件,因此在使用该模块前需要完成VCS的安装。 注2 git是Puppet公司唯一官方支持的vcs provider

1.先睹为快

不想看下面大段的代码解析,已经跃跃欲试了?

OK,我们开始吧!

创建一个git.pp文件并输入:

vcsrepo { '/tmp/git_repo':
  ensure   => present,
  provider => git,
}

打开虚拟机终端并输入以下命令:

$ puppet apply -v git.pp

该命令将会创建一个git仓库,其路径是'/tmp/git_repo'。

2.使用示例

puppet-vcsrepo模块除了自定义资源类型vcsrepo以外,并没有任何manfests代码。因此,本节主要介绍使用vcsrepo来管理git仓库。

例1: 创建和管理一个空的git bare仓库:

vcsrepo { '/path/to/repo':
  ensure   => bare,
  provider => git,
}

例2:clone/pull一个repo:

vcsrepo { '/path/to/repo':
  ensure   => present,
  provider => git,
  source   => 'git://example.com/repo.git',
}

例3:指定branch或tag:

注3:默认vcsrepo会使用源仓库master分支的HEAD。若要使用其他分支或指定的commit,可以设置revision来指定branch名称或commit SHA值或者tag号

  • 指定Branch:

    vcsrepo { '/path/to/repo':
    ensure   => present,
    provider => git,
    source   => 'git://example.com/repo.git',
    revision => 'development',
    }
  • 指定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',
    }

例4:保持repo为最新代码:

vcsrepo { '/path/to/repo':
  ensure   => latest,
  provider => git,
  source   => 'git://example.com/repo.git',
  revision => 'master',
}

例5:clone repo,但是跳过初始化submodule:

vcsrepo { '/path/to/repo':
  ensure     => latest,
  provider   => git,
  source     => 'git://example.com/repo.git',
  submodules => false,
}

例6:设置多个source,必须指定明确的remote:

vcsrepo { '/path/to/repo':
  ensure   => present,
  provider => git,
  remote   => 'origin'
  source   => {
    'origin'       => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git',
    'other_remote' => 'https://github.com/other_user/puppetlabs-vcsrepo.git'
  },
}

例7:使用指定用户的SSH密钥来clone repo:

csrepo { '/path/to/repo':
  ensure     => latest,
  provider   => git,
  source     => 'git://username@example.com/repo.git',
  user       => 'toto', #uses toto's $HOME/.ssh setup
  require    => File['/home/toto/.ssh/id_rsa'],
}

2.1 Git支持的特性和参数

特性:

  • bare_repositories

  • depth

  • multiple_remotes

  • reference_tracking

  • ssh_identity

  • submodules

  • user

参数:

  • depth

  • ensure

  • excludes

  • force

  • group

  • identity

  • owner

  • path

  • provider

  • remote

  • revision

  • source

  • user

3.动手练习

1.使用vcsrepo管理nova源码仓库,并使用stable/ocata分支 2.使用vcsrepo管理一个带有submodule的项目,并指定管理submodule

若要使用SSH方式连接到源码仓库,推荐使用Puppet来管理SSH密钥,并使用元参数来确保它们间的执行顺序。

require
https://github.com/puppetlabs/puppetlabs-vcsrepo
先睹为快
使用示例
动手练习