To create a puppet warehouse as an example build a git server
First, build a git server
1. Install the GIT package on the server
#yum Install git Git-daemon
2, create a dedicated account on the server, all users through this account access to the Git library. Choose Git as your dedicated account and set a password for your account. (You can also modify Git to allow only public key authentication to enhance security after you have configured the GIT service.) )
#adduser-S/bin/bash git
#passwd git
3. Initialize the puppet server git repository, create the/git directory, create the puppet repo directory under/git directory, and give Git user rights:
Create a/git directory
#mkdir/git
Create puppet Repo Directory
#mkdir/git/puppet.git
Create a git repository
#cd/git/puppet.git
#git--bare Init
Give git directory git user rights
#chown Git:git-r/git
4. Start the Git service,
#/usr/libexec/git-core/git-daemon--base-path=/git--detach--user=git--group=git--listen=10.240.216.250-- Export-all--enable=receive-pack--enable=upload-pack--enable=upload-archive
Second, descending puppet join Git
1, the/etc/puppet directory on puppet Master is added to the warehouse as a copy of the warehouse.
#cd/etc/
#mv puppet/tmp
Clone the previously built puppet warehouse into/etc directory and produce a puppet directory under this directory.
#git Clone Git://10.240.216.250/puppet.git
#cd/etc/puppet
#cp/tmp/puppet/*
#git Add *
#git commit-m "Add puppet to Git repo"
#git Push-u Origin Master
Counting objects:2949, done.
Delta compression using up to threads.
Compressing objects:100% (2630/2630), done.
Writing objects:100% (2949/2949), 1.57 MiB, done.
Total 2949 (Delta 611), reused 0 (Delta 0)
To Git://10.240.216.250/puppet.git
* [New branch] Master, master
This creates a master repository locally, which contains the configuration files and checklists for the puppet. We can export multiple copies in a non-accessible location and submit the work on those copies before the change. GCA, we have a team of system administrators, each of whom can create a copy of the work on their own computer for modification.
Third, create a copy on the system administrator's local computer (that is, the GIT client)
1. Clone puppet Copy to Local
[Email protected]:# cd/tmp
[Email protected]:/tmp#
[Email protected]:/tmp# git clone git://10.240.216.250/puppet.git
Cloning into ' puppet ' ...
Remote:counting objects:2949, done.
Remote:compressing objects:100% (2019/2019), done.
Remote:total 2949 (Delta 611), reused 2949 (Delta 611)
Receiving objects:100% (2949/2949), 1.57 MiB | 0 bytes/s, done.
Resolving deltas:100% (611/611), done.
Checking connectivity ... done.
[Email protected]:/tmp#
[Email protected]:/tmp# ls
Puppet
2. Modify the configuration you want to modify and submit to the main branch "master"
[Email protected]:/tmp# CD puppet
[Email protected]:/tmp/puppet# ls
AAA auth.conf Environments fileserver.conf hieradata Hiera.yaml manifests modules puppet.conf
[Email protected]:/tmp/puppet# VI manifests/site.pp
Package {
Allow_virtual = True,
}
Node ' bgw-os-node1 ' {
Include:: Openstack::role::controller_master
}
Node ' Bgw-os-node2 ' {
Include:: Openstack::role::controller_standby
}
Node ' Bgw-os-node11 ' {
Include:: Openstack::role::compute
}
#node ' bgw-os-node12 ' { #此处是要修改的内容, comment out the node12 node
# include:: Openstack::role::compute
#}
Node ' bgw-os-node151 ' {
Include:: Openstack::role::ceph_mon_and_osd
}
Node ' bgw-os-node152 ' {
Include:: Openstack::role::ceph_mon_and_osd
}
Node ' bgw-os-node153 ' {
Include:: Openstack::role::ceph_mon_and_osd
}
"Puppet/manifests/site.pp" 31L, 544C written
[Email protected]:/tmp# git add puppet/manifests/site.pp
Fatal:not a git repository (or any of the parent directories):. git
[Email protected]:/tmp/puppet# git add manifests/site.pp
[Email protected]:/tmp/puppet# git commit-m "Add site.pp"
Please tell me who is you.
Run
git config--global user.email "[Email protected]"
git config--global user.name "Your name"
To set your account ' s default identity.
Omit--global to set the identity of the This repository.
Fatal:unable to Auto-detect email address (got ' [email protected] (none)
Above error, need to add user and user's mailbox
[email protected]:/tmp/puppet# git config--global user.name "Lizhanguo"
[email protected]:/tmp/puppet# git config--global user.email "[Email protected]"
Commit successfully again
[Email protected]:/tmp/puppet# git commit-m "Add site.pp"
[Master 894DA1E] ADD site.pp
1 file changed, 3 insertions (+), 3 deletions (-)
[Email protected]:/tmp/puppet#
Push local content to the GIT server side
[Email protected]:/tmp/puppet# git push
Warning:push.default is unset; Its implicit value have changed in
Git 2.0 from ' matching ' to ' simple '. To squelch the This message
and maintain the traditional behavior, use:
git config--global push.default matching
To squelch this message and adopt the new behavior now, use:
git config--global push.default simple
When Push.default was set to ' matching ', git would push local branches
To the remote branches, which already exist with the same name.
Since git 2.0, git defaults to the + Conservative ' simple '
Behavior, which only pushes the current branch to the corresponding
Remote branch that ' git pull ' uses to update the current branch.
See "git help config" and search for ' push.default ' for further information.
(the ' simple ' mode is introduced in Git 1.7.11. Use the similar mode
' Current ' instead of "simple" if you sometimes use older versions of Git)
Counting Objects:4, done.
Delta compression using up to 2 threads.
Compressing objects:100% (3/3), done.
Writing objects:100% (4/4), 376 bytes | 0 bytes/s, done.
Total 4 (Delta 2), reused 0 (Delta 0)
To Git://10.240.216.250/puppet.git
5ad9866. 894DA1E Master, Master
[Email protected]:/tmp/puppet#
Git server, run git pull in puppet Master's/etc/puppet directory and update it to the latest version.
[[email protected] puppet]# git pull
Remote:counting objects:7, done.
Remote:compressing objects:100% (3/3), done.
Remote:total 4 (Delta 2), reused 0 (Delta 0)
Unpacking objects:100% (4/4), done.
From Git://10.240.216.250/puppet
5ad9866. 894DA1E Master--Origin/master
Updating 5ad9866. 894da1e
Fast-forward
manifests/site.pp | 6 + +---
1 files changed, 3 insertions (+), 3 deletions (-)
See if the client's modification submission takes effect
[email protected] puppet]# cat manifests/site.pp
Package {
Allow_virtual = True,
}
Node ' bgw-os-node1 ' {
Include:: Openstack::role::controller_master
}
Node ' Bgw-os-node2 ' {
Include:: Openstack::role::controller_standby
}
Node ' Bgw-os-node11 ' {
Include:: Openstack::role::compute
}
#node ' bgw-os-node12 ' { #已生效
# include:: Openstack::role::compute
#}
Node ' bgw-os-node151 ' {
Include:: Openstack::role::ceph_mon_and_osd
}
Node ' bgw-os-node152 ' {
Include:: Openstack::role::ceph_mon_and_osd
}
Node ' bgw-os-node153 ' {
Include:: Openstack::role::ceph_mon_and_osd
}
2, in order to ensure the real-time update, we can increase the scheduled task in Cron to ensure that the content of the/etc/puppet copy is updated every minute.
[Email protected] ~]# CRONTAB-E
No crontab for root-using an empty one
*/1 * * * * CD/ETC/PUPPET; Git pull
This article is from the "zhanguo1110" blog, make sure to keep this source http://zhanguo1110.blog.51cto.com/5750817/1603671
Redhat Build a git server