puppet agent run backup of cron files - puppet

Looks like I was having wrong entry in root crontab and when I ran puppet agent it got overwritten.
Error: Could not prefetch cron provider 'crontab': Could not parse line "====" at root:10
Is there any way to recover those cron entries which was there before I run puppet agent?

Related

Automatically apply puppet catalog upon login to client node

I tried to execute shell script automatically when a user logins to a Puppet client node. I need to trigger puppet agent --test on a puppet client when a user logins to it.
I need to execute "puppet agent -t" command automatically when any user login to puppet client machine
That is going to be problematic, as puppet needs to run as root.
You can add
sudo puppet agent -t
to your /etc/profile , and also add
ALL ALL=(ALL) NOPASSWD: puppet
to your /etc/sudoers file.
But this is NOT something I would recommend.

puppet agent --test throwing environment errors

I am trying to keep puppet master and client/agent on one machine. I have been trying this for last 2 days and I am almost close to finishing it.
1) started puppet master "service puppetmaster start". Its successful
2) started puppet agent "service puppet start. Its successful
3) When I try puppet agent --test. see the errors below
This is the error I am getting when I try "puppet agent --test". I tried setting different values for environment in puppet.conf file and also passing from command line args for environment but nothing seems to be working.
Warning: Local environment: "production" doesn't match server
specified environment "none", restarting agent run with environment
"none"
I googled and tried what people said, but no use. It might work if I try agent from one machine and master on the other. But I want to make it work on one machine.
If you want to make it work on one machine you don't use puppet agent -t. you should use puppet apply. here is a reference
https://docs.puppet.com/puppet/latest/re‌​ference/man/‌​apply.html
you can write a small script which will be having puppet apply command with farther argument (of course) and you can name it whatever you want (e.g: Papply) and run it every time whenever you want to run puppet agent -t.
puppet agent -t is not preferred for stand alone Puppet Server & Clint environment.
https://docs.puppet.com/puppet/4.6/reference/architecture.html

Jenkins error on building command?

I am new to Jenkins, starting now.
I see the following errors here.
Building in workspace /var/lib/jenkins/workspace/GIF_DECODER
[GIF_DECODER] $ /bin/bash /tmp/hudson3370393570271110742.sh
/tmp/hudson3370393570271110742.sh: line 2: cd: /home/joshis1/Data/E-Drive/Blog/Ready_to_post/Ubuntu/GIF_Decoder_LINUX: Permission denied
/var/lib/jenkins/workspace/GIF_DECODER
I have given the build commands as the following. This is under execute shell.
#!/bin/bash
cd /home/joshis1/Data/E-Drive/Blog/Ready_to_post/Ubuntu/GIF_Decoder_LINUX
pwd
make clean
make everything
I am not understanding what is the issue here? Looks to be a permission year. I have jenkins in sudoers list. I don't why it looks for /var/lib/jenkins/workspace/GIF_Decoder.
I see the jenkins page under - http://:8080/job/GIF_DECODER/configure
How can I setup the hostname so that instead of localhost I have some meaningful name? Please help. Also, what is the best document/video to start with Jenkins for linux users? How to debug Jenkins issue seen? How can I instantiate a build by sending an email?
I am not understanding what is the issue here?
It's a permission error. It looks like your jenkins user does not have permissions for /home/joshis1/Data/E-Drive/Blog/Ready_to_post/Ubuntu/GIF_Decoder_LINUX
How can I setup the hostname so that instead of localhost I have some meaningful name?
Try the hostname of your server in the URL. e.g. http://myserver:8080/job/GIF_DECODER/configure
Also, what is the best document/video to start with Jenkins for linux users?
I expect that you have a basic understanding of how linux works. This is important on how to configure your jenkins and write the necessary build steps. The most basic information you will find on http://jenkins-ci.org and basic installation https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins
How to debug Jenkins issue seen?
That depends ...
... on the issue. If you have build problems check the console output of the job first. In addition, Jenkins writes its logfiles into the jenkins home directory.
How can I instantiate a build by sending an email?
Check out the mail commander plugin

Cronjob on Amazon EC2 Deleted?

I had a cronjob set up to run a php script daily, which went well for about a month. Today, I realized it didn't run the script so I opened up the crontab. The crontab is completely empty - what happened?
I don't know too much about cronjobs, but as far as I understand, they do not delete themselves if the server is reset. How can I make sure cronjobs are always running and that it doesnt get deleted?
It is probably under a different user. Check root user sudo crontab -e. Each user has it's own crontab and there's one for the whole system. Note: Through the crontab configuration you can disable per-user crontabs.

getting No such file or directory error for cron job

I wanted to run the following file from a cron job and got No such file or directory error, please help.
/var/www/vhosts/domain.com/httpdocs/filename.php
Just use a service like WebBasedCron (google it) to schedule your cron job remotely. If you can access the filename.php file from a browser like FireFox, then you can execute the cron job.

Resources