git clone throws error with vcsrepo module puppet - linux

I am following the pluralsight's tutorial for puppet fundamentals by Ben Piper.
When installing the "vcsrepo" module in agents and downloading the repository the puppet agent run hangs.
Below is the excerpt from my puppet master "init.pp" file
I changed my puppetmaster init.pp file to use the ssh instead.
`file { '/home/vagrant/.ssh/id_rsa':
ensure => 'present',
}
vcsrepo { '/var/www/html':
ensure => 'present',
provider => 'git',
source => 'git#github.com:wikimedia/mediawiki.git',
user => 'vagrant',
revision => 'REL1_23',
require => File['/home/vagrant/.ssh/id_rsa'],
}
file { '/var/www/html/index.html':
ensure => 'absent',
}
File['/var/www/html/index.html'] -> Vcsrepo['/var/www/html']`
It now throws the below error
Notice: /Stage[main]/Linux/File[/info.txt]/content: content changed '{md5}dd4735ab73567a89caba62c6607e44b5' to '{md5}e30fa7cc7448a09071a0e4d33efa5986'
Notice: /Stage[main]/Mediawiki/Vcsrepo[/var/www/html]/ensure: Creating repository from present
Error: Execution of 'git clone git#github.com:wikimedia/mediawiki.git /var/www/html' returned 1:
Error: /Stage[main]/Mediawiki/Vcsrepo[/var/www/html]/ensure: change from absent to present failed: Execution of 'git clone git#github.com:wikimedia/mediawiki.git /var/www/html' returned 1:
I have shared my system's public key in github account

On Linux
Execute the following in the command line before executing the Git command:
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1
On Windows
Execute the following in the command line before executing the Git command:
set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1
Cause
Error code 56 indicates a curl receive error of CURLE_RECV_ERROR which means there was some issue that prevented the data from being received during the clone process. Typically this is caused by a network setting, firewall, VPN client, or anti-virus that is terminating the connection before all data has been transferred.
Workaround
Switch to using SSH to perform the clone.

Related

Troubleshooting Puppet Manifests for Windows puppet Node

I have puppet manifests which would download exe file and get installed in windows server.I am getting an error while running command: puppet agent -t on windows server.
Manifests file: /etc/puppet/modules/mercury/manifests/iisserver.pp
class mercury::iisserver {
download_file { "Download dotnet core 2":
url => 'http://download.microsoft.com/download/7/3/A/73A3E4DC-F019-47D1-9951-0453676E059B/dotnet-sdk-2.0.2-win-gs-x64.exe',
destination_directory => 'C:/dotnet-sdk-2.0.2-win-gs-x64.ex',
notify => Package["dotnercore2"],
}
package { "dotnercore2":
ensure => installed,
source => "C:/dotnet-sdk-2.0.2-win-gs-x64.exe",
require => File["C:/dotnet-sdk-2.0.2-win-gs-x64.exe"],
}
}
Error on windows server after running Puppet agent -t:
Error :Could not retreive catalog from remote server:error 400 on server:Syntax error at 'Stdlib::HTTPUrl'; Expected')' at /etc/puppet/modules/download_file/manifests/init.pp on node XXXX
Warning : not using cache on failed catalog.
Error: Could not retrieve catalog; Skipping run
If you look closely, your error output shows what is wrong. There is a Syntax error with your HTTPUrl on your /etc/puppet/modules/download_file/manifests/init.pp file. It is expecting a ')' character somewhere. Could you recheck your manifest for the download_file module or post it here so that we can review :)

Squelch puppet state chown

I'm hoping to use puppet to manage my rc files (i.e. sharing configuration files between work and home). I keep my rc files in a subversion respository. Some machines, I have sudo privileges on, some I don't. And none of the machines are on the same network.
I have a simple puppet file:
class bashResources ( $home, $svn ) {
file { "$home/.bash" :
ensure => 'directory',
}
file { "$home/.bash/bashrc.d" :
ensure => 'directory',
}
file { "$home/.bash/bashrc.d/bashrc" :
ensure => present,
target => "$home/$svn/rc/bashrc",
}
}
node 'ubuntuwgu290' {
class { 'bashResources':
home => '/home/dshaw',
svn => 'mysvn',
}
}
I have a simple config file that I'm using to squelch some errors:
[main]
report=false
When I run puppet, I get an annoying error about not being able to execute chown:
dshaw#ubuntuwgu290:~/mysvn/rc$ puppet apply rc.pp --config ./puppet.conf
Notice: Compiled catalog for ubuntuwgu290.maplesoft.com in environment production in 0.12 seconds
Error: Failed to apply catalog: Operation not permitted # rb_file_chown - /home/dshaw/.puppet/var/state/state.yaml20170316-894-rzkggd
Error: Could not save last run local report: Operation not permitted # rb_file_chown - /home/dshaw/.puppet/var/state/last_run_summary.yaml20170316-894-l9embs
I have attempted to squelch the error by adding reports=none to my config file, but it has not been effective.
How can I squelch these errors? Alternatively, is there a more lightwieght tool for managing rc files?
Thanks,
Derek
The error is related to Puppet trying to manage its own metadata in /home/dshaw/.puppet, not any of the files enrolled in Puppet's catalog for management. This is not normally a problem, even when you run Puppet as an ordinary user. In fact, supporting this sort of thing is one of the reasons why per-user Puppet metadata exists.
The files that Puppet is trying to chown do not already belong to you (else Puppet would not be trying to chown them), but they should belong to you, where "you" means the puppet process's (e)UID and (e)GID. You might be able to solve the problem by just removing Puppet's state directory, and letting it rebuild it on the next run. Alternatively, you might be able to perform or arrange for a manual chown such as Puppet is trying to perform.
On the other hand, it's unclear how this situation arose in the first place, and some of the mechanisms I can imagine would render those suggestions ineffective.

Error while downloading JAR file from repo

I'm trying to download a JAR file from a repo, but I'm getting the below error:
pget { 'Download 123 jar file':
source => 'url'
target => 'C:\download,
targetfilename => '123.jar',
require => File['E:\download'],
}
I'm getting the below error while executing the resource
Error: Evaluation Error: Error while evaluating a Resource Statement, Unknown resource type: 'pget'
Can anyone explain why I cannot use pget? Is there any other way to download the JAR file?
You either forgot to install the module that provides the pget type, or it was not installed correctly: https://forge.puppet.com/cyberious/pget
Install it either locally (using puppet apply) or on the master (using puppet agent) with:
puppet module install cyberious-pget
and then your resource will work.

Puppet + Beaker + Travis: acceptance test failing

I A have a Puppet module with acceptance tests based on Beaker. The module is working fine and when running locally all the acceptance tests run fine. But when I run the tests on Travis I got the following error in the module execution:
/Stage[main]/Alfred::Services/Service[alfred]: Could not evaluate: undefined method `[]' for nil:NilClass
Alfred is a system service based on upstart that is part of my module.
I am using Puppet 4.3.2. Here is the travis build: https://travis-ci.org/nicopaez/alfred-puppet
Any idea?
Looking at the code, there's a few issues.
One is that the environment variable you're using in Travis doesn't set the Puppet version. You need to add that code to your spec_helper_acceptance.rb:
hosts.each do |host|
install_puppet_on(host,
:puppet => ENV['PUPPET_VERSION'] || '4.3.2',
)
end
Right now it's still installing Puppet 3.8 (the default latest)
For further information on what is actually causing the issues in Travis, I forked your repo and did a build where I enabled the debug and trace options for beaker:
result = apply_manifest(pp, :trace => true, :debug => true)
From this, looking at the Travis build, theres an issue with the git clone exec:
Debug: Exec[clone-repo](provider=posix): Executing 'git clone https://github.com/fiuba/alfred.git /var/www/alfred'
Debug: Executing 'git clone https://github.com/fiuba/alfred.git /var/www/alfred'
Notice: /Stage[main]/Alfred::App/Exec[clone-repo]/returns: fatal: Could not change back to '/root': Permission denied
Error: git clone https://github.com/fiuba/alfred.git /var/www/alfred returned 128 instead of one of [0]
You could fix this by using the vcsrepo module, which performs git clones in an more idempotent way:
vcsrepo { '/var/www/alfred':
ensure => present,
source => 'https://github.com/fiuba/alfred.git',
provider => git,
user => 'deployer',
}
There's a few other fixes, I'm PRing some fixes to your module to fix them, and will add a summary here to the Stack Overflow answer after you've reviewed and merged, as some are significant refactors with a few different approaches.

Puppet pass SSH keys to VM for us in Git

I'm using Vagrant to provision a VM onto DigitalOcean using config from PUPHPET. I need to clone a private git repo. I've created an SSH key to be used to authenticate the request using the Puppet vcsrepo module but it seems my SSH key isn't being picked up properly.
I've set Vagrant config.ssh.forward_agent to true and config.ssh.private_key_path points to my local rsa file on my mac. This is also used for the DigitalOcean key.
I can see my key in ~/.ssh/authorized_keys on the VM.
The git clone fails if it's a private repo. I tried with a public repo and it is successful.
Here is the Puppet vcsrepo command:
vcsrepo { '/var/www/html':
ensure => present,
provider => git,
source => 'https://******#bitbucket.org/****.git',
require => '~/.ssh/authorized_keys',
}
This gives the error No title provided and "~/.ssh/authorized_keys" is not a valid resource reference at /tmp/vagrant-puppet/manifests-893fcd
I also tried with the identity property:
vcsrepo { '/var/www/html':
ensure => present,
provider => git,
source => 'https://******#bitbucket.org/****.git',
identity => '~/.ssh/authorized_keys',
force => true
}
This gives fatal: could not read Password for 'https://billyjones#bitbucket.org': No such device or address
Using Debian 7.

Resources