I am trying to pass a facter argument to puppet apply. Here's what I tried:
export FACTER_command="start"
puppet apply site.pp $FACTER_command
and in my code I have:
exec { 'some_exec':
command => '/bin/bash -c "/some/path/to/scripts.sh -t some_arg $::command"',
...
I get this message error:
Error: '/bin/bash -c "/some/path/to/scripts.sh -t some_arg $::command"' returned 1 instead of one of [0]
Error: /Stage[main]/Standard/Exec[some_exec]/returns: change from 'notrun' to ['0'] failed: '/some/path/to/scripts.sh -t some_arg $::command"' returned 1 instead of one of [0]
Does anyone have any idea about this?
UPDATE
class standard{
$param_test="/some/path/to/scripts.sh -t some_arg ${::command}"
file{'kick_servers':
ensure => 'file',
path => '/some/path/to/scripts.sh',
owner => 'some_user,
group => 'some_user',
mode => '0755',
notify => Exec['some_exec']
}
exec { 'some_exec':
command => '/bin/bash -c ${param_test}',
cwd => "$home_user_dir",
timeout => 1800
}
}
node default {
include standard
}
And I get this error
Error: '/bin/bash -c $param_test' returned 2 instead of one of [0]
Error: /Stage[main]/Standard/Exec[some_exec]/returns: change from 'notrun' to ['0'] failed: '/bin/bash -c $param_test' returned 2 instead of one of [0]
Yes. You have at least two issues you need to fix there:
1/
The immediate cause of your problem is you have enclosed $::command inside single quotes, telling Puppet that you mean the literal string $::command, when you actually want the value of the fact there.
2/
You should not be passing $FACTER_command as an argument to puppet apply; you only need to export it as an environment variable (which you already did).
So:
Change puppet apply to:
puppet apply site.pp
Change your exec to:
exec { 'some_exec':
command => "/bin/bash -c '/some/path/to/scripts.sh -t some_arg ${::command}'",
...
}
Related
I put this in my zshrc:
function picofl() {
openocd -f interface/picoprobe.cfg -f target/rp2040.cfg -c 'program "$1" reset exit'
}
Then I run: picofl myblink.elf but it errors with unexpected argument. What am I doing wrong?
For my data analysis pipeline I am using nextflow (which is a workflow management system) and I gave all the required arguments in the main command but I am getting a weird error. Basically in the output section I introduce the output but the error is missing output. I have made 3 files to run the pipeline including:
1- the module containing the main code to run the tool (ASEReadCounter) and named ASEReadCounter.nf :
process ASEReadCounter {
input:
file vcf_file
file bam_file
path(genome_fasta)
output:
file "${vcf_file}.ASE.csv"
script:
"""
gatk ASEReadCounter \\
-R ${params.genome} \\
-V ${params.vcf_infile} \\
-O ${params.vcf_infile}.txt \\
-I ${params.bam_infile}
"""
}
2- the main file which is used to run the pipeline named main.nf :
#!/usr/bin/env nextflow
nextflow.preview.dsl=2
include ASEReadCounter from './modules/ASEReadCounter.nf'
genome_ch = Channel.fromPath(params.genome)
vcf_file_ch=Channel.fromPath(params.vcf_infile)
bam_infile_ch=Channel.fromPath(params.bam_infile)
workflow {
count_ch=ASEReadCounter(genome_ch, vcf_file_ch, bam_infile_ch)
}
3- config file which is named nextflow.config :
params {
genome = '/hpc/hg38_genome/GRCh38.p13.genome.fa'
vcf_infile = '/hpc/test_data/test/test.vcf.gz'
bam_infile = ‘/hpc/test_data/test/test.sorted.bam'
}
process {
shell = ['/bin/bash', '-euo', 'pipefail']
withName: ASEReadCounter {
container = 'broadinstitute/gatk:latest'
}
}
singularity {
enabled = true
runOptions = '-B /hpc:/hpc -B $TMPDIR:$TMPDIR'
autoMounts = true
cacheDir = '/hpc/diaggen/software/singularity_cache'
}
here is the command I use to run the whole pipeline:
nextflow run -ansi-log false main.nf
Here is the error I am getting:
Error executing process > 'ASEReadCounter (1)'
Caused by:
Missing output file(s) `GRCh38.p13.genome.fa.ASE.csv` expected by process `ASEReadCounter (1)`
Command executed:
gatk ASEReadCounter -R /hpc/hg38_genome/GRCh38.p13.genome.fa \
-V /hpc/test_data/test/test.vcf.gz \
-O /hpc/test_data/test/test.vcf.gz.txt \
-I /hpc/test_data/test/test.sorted.bam
Do you know how I can fix the error?
Your ASEReadCounter process expects a file with the pattern ${vcf_file}.ASE.csv as output, as defined at:
output:
file "${vcf_file}.ASE.csv"
I assume the line -O ${params.vcf_infile}.txt makes it so your gatk ASEReadCounter command writes its output to a file with the pattern $params.vcf_infile}.txt. The expected output and the actual output filenames don't match and nextflow throws an error because it doesn't want to contine since a downstream process might need the output file. You can fix it by matching the expected output and actual output patterns,
This is hard to explain for me, however.
I want to push a time off set to puppet for a cron job.
define cron::job (
$url,
$time_offset,
$ensure = 'present',
$minute = 5 + $time_offset,
)
Then in my actual job I want to use */ as well as the minute variable. Is this possible? As my current implementation is failing and I can't seem to find the answer in the docs which suggests I'm going about this the complete incorrect way.
This is my cron job.
cron { "job":
command => "wget -O - --save-cookies cookies.txt --load-cookies cookies.txt --keep-session-cookies https://${url}/ >/dev/null 2>/dev/null",
user => 'housekeeper',
minute => '*/$minute',
ensure => $ensure,
}
I would appreciate any feedback / suggestions.
Would I be better off just using a set minute rather than every 5 minutes for example?
The reason I want to do this, is I want to leave the cron jobs the same and just pass an offset to the class for each site.
This works:
define cron::job (
$url,
$time_offset,
) {
$minute = 5 + $time_offset
cron { "cron ${name}":
ensure => present,
command => "wget -O - --save-cookies cookies.txt --load-cookies cookies.txt --keep-session-cookies https://${url}/ >/dev/null 2>/dev/null",
user => 'housekeeper',
minute => "*/${minute}",
require => User['housekeeper'],
}
}
user { 'housekeeper':
ensure => present,
}
cron::job { 'job1':
url => 'http://example1.com',
time_offset => 10,
}
cron::job { 'job2':
url => 'http://example2.com',
time_offset => 15,
}
Then
[root#centos-72-x64 ~]# puppet apply /tmp/foo.pp
Notice: Compiled catalog for centos-72-x64 in environment production in 0.21 seconds
Notice: /Stage[main]/Main/User[housekeeper]/ensure: created
Notice: /Stage[main]/Main/Cron::Job[job2]/Cron[cron job2]/ensure: created
Notice: /Stage[main]/Main/Cron::Job[job1]/Cron[cron job1]/ensure: created
Notice: Finished catalog run in 0.05 seconds
And
[root#centos-72-x64 ~]# cat /var/spool/cron/housekeeper
# HEADER: This file was autogenerated at 2016-04-12 11:29:15 +0000 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: cron job2
*/20 * * * * wget -O - --save-cookies cookies.txt --load-cookies cookies.txt --keep-session-cookies https://http://example2.com/ >/dev/null 2>/dev/null
# Puppet Name: cron job1
*/15 * * * * wget -O - --save-cookies cookies.txt --load-cookies cookies.txt --keep-session-cookies https://http://example1.com/ >/dev/null 2>/dev/null
I am trying to install the RabbitMQ module on my virtual machine. I used :
git submodule add https://github.com/puppetlabs/puppetlabs-rabbitmq.git
and I installed every dependecy I could find the same way (which are, like listed in this answer : stdlib, epel, staging and erlang).
I reduced my manifest to the bare minimum :
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
exec { 'apt-get update':
command => 'apt-get update',
timeout => 60,
tries => 3
}
package { ['python-software-properties']:
ensure => 'installed',
require => Exec['apt-get update'],
}
$sysPackages = [ 'build-essential', 'git', 'curl']
package { $sysPackages:
ensure => "installed",
require => Exec['apt-get update'],
}
include epel
include staging
class { 'erlang': epel_enable => true}
class { 'rabbitmq':
port => '5672',
service_manage => true,
environment_variables => {
'RABBITMQ_NODENAME' => 'server',
'RABBITMQ_SERVICENAME' => 'rabbitMQ'
}
}
And when I provision my VM with vagrant provision, I get the error :
==> default: Error: Invalid parameter include_src at /tmp/vagrant-puppet/modules
-33d06c2339c7ee7ab2bd92b2d11cf5d9/erlang/manifests/repo/apt.pp:39
I'm almost certain it is because of a dependency I do not have, but I can not find out which one. Any ideas ?
It seems that erlang module requires older version of apt module. Look at this patch. Recently, in apt resource, parameters include_src and include_deb were substituted by one include parameter. To solve the problem please install apt module in version 1.8.0.
I'm using Vagrant and Puppet for the first time in a project and I keep running into an issue.
I've used PuPHPet as a starting point, and I have the following snippet in my default.pp manifest:
class { 'apache': }
apache::dotconf { 'custom':
content => 'EnableSendfile Off',
}
apache::module { 'rewrite': }
apache::vhost { 'awesome.dev':
server_name => 'awesome.dev',
serveraliases => [
],
docroot => '/var/www',
port => '80',
directories => [ { path => '/var/www/', allow => 'from all', allow_override => ['All'] } ],
env_variables => [],
priority => '1',
}
When I run it, I always get the following error:
warning: Could not retrieve fact fqdn
Invalid parameter directories at /tmp/vagrant-puppet/manifests/default.pp:46 on node precise32
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
cd /tmp/vagrant-puppet/manifests && puppet apply --verbose --modulepath '/etc/puppet/modules:/tmp/vagrant-puppet/modules-0' default.pp --detailed-exitcodes || [ $? -eq 2 ]
Line 46 is the end of the apache::vhost rule. I want to set it to allow override using htaccess, but I can't see where I've gone wrong. Can anyone see what the issue is?
PuPHPet uses the Example42 Apache Puppet module, see the README file. This module doesn't have a directories parameter in the vhost resource:
https://github.com/puphpet/puphpet-apache/blob/master/manifests/vhost.pp#L100
Only the Puppet Labs Apache module has a directories parameter, but it's a different module:
https://github.com/puppetlabs/puppetlabs-apache/blob/master/manifests/vhost.pp#L25
You can however use the directory parameter in Example42's module similarly to the example which can be found in the vhost resource:
# apache::vhost { 'my.other.site':
# docroot => '/path/to/docroot',
# directory => '/path/to',
# directory_allow_override => 'All',
# }