I am not sure what I am doing wrong and the examples I have googled seem to suggest this is allowed (I basically copied/pasted).
#
# Configure MySQL
#
package { 'mysql-server':
ensure => installed,
}
service { 'mysql':
ensure => running,
enable => true
}
exec { 'set-mysql-password':
unless => 'mysqladmin -uroot -proot status',
command => "mysqladmin -uroot password ALEXWASHERE",
path => ['/bin', '/usr/bin'],
require => Service['mysql'];
}
#mysql:db { 'apps':
# user => 'aerospace_erp',
# password => 'ALEXWASHERE',
# host => 'localhost',
# grant => ['SHOW VIEW', 'SELECT', 'UPDATE', 'INSERT', 'DELETE']
#}
This results in the following errors:
==> default: Error: /Stage[main]/Main/Service[mysql]: Could not evaluate: Could not find init script for 'mysql'
==> default: Notice: /Stage[main]/Main/Package[mysql-server]/ensure: ensure changed 'purged' to 'present'
==> default: Notice: /Stage[main]/Main/Exec[set-mysql-password]: Dependency Service[mysql] has failures: true
==> default: Warning: /Stage[main]/Main/Exec[set-mysql-password]: Skipping because of failed dependencies
Not sure whats going on???
Alex
In Linux OS,
service is mysqld not mysql
service { "mysqld" : ensure => running,}
Related
Getting error 500
puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not find node statement with name 'default' or 'client.domain.com' on node client.domain.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Puppet.conf content below:
[master]
dns_alt_names = master.domain.com,server
certname = master.domain.com
[agent]
server = master.domain.com
ca_server = master.domain.com
certname = client.domain.com
use_cached_catalog = true
Your site.pp file under the manifests folder need to contain either a node 'client.domain.com' (as client.domain.com is your certname for the agent) or a node default.
For instance:
node default {
file { '/tmp/puppetdir':
ensure => 'directory',
owner => 'sysadmin',
group => 'wheel',
mode => '0755'
}
}
node 'client.domain.com' {
package { 'httpd':
ensure => "installed",
}
service { 'httpd':
ensure => running,
enable => true
}
file { '/tmp/puppetdir':
ensure => 'directory',
owner => 'sysadmin',
group => 'wheel',
mode => '0755'
}
}
I am getting an error on the snoopy module. When I run it on my client, I am getting this error:
"Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class snoopy::install at /etc/puppet/modules/snoopy/manifests/init.pp:22 on node <hostname>
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run"
Any ideas what I am doing wrong here? This is the snoopy module from git with a couple of modifications for our environment. https://forge.puppet.com/revolutionsystem/snoopy
install.pp
$ cat install.pp
# snoopy::install
#
# A description of what this class does
#
# #summary A short summary of the purpose of this class
#
# #example
# include snoopy::install
class snoopy::install {
# Download snoopy installation script
file { '/tmp/snoopy':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
} ->
exec { 'wget installer':
command => "/usr/bin/wget http://159.79.213.28/pub/PUPPET/snoopy- install.sh",
creates => "/tmp/snoopy/snoopy-install.sh",
require => [ File['/tmp/snoopy'], ];
} ->
# Install Snoopy stable version
exec { '/tmp/snoopy/snoopy-install.sh stable':
cwd => '/tmp/snoopy',
command => '',
path => [ '/bin/bash' ],
unless => [ 'test -f /tmp/snoopy/snoopy-install.sh']
require => [ File['/tmp/snoopy'], File['/tmp/snoopy/snoopy- install.sh'], ];
}
}'
$ cat init.pp
# snoopy
#
# A description of what this class does
#
# #summary A short summary of the purpose of this class
#
# #example
# include snoopy
class snoopy (
$user_name = $::snoopy::params::username,
$user_id = $::snoopy::params::userid,
$group_id = $::snoopy::params::groupid,
$super_id = $::snoopy::params::superid,
$terminal = $::snoopy::params::terminal,
$current_directory = $::snoopy::params::currentdirectory,
$process_id = $::snoopy::params::processid,
$file_name = $::snoopy::params::filename,
$log_file = $::snoopy::params::logfile,
$log_path = $::snoopy::params::logpath,
$date_time = $::snoopy::params::datetime
) inherits snoopy::params {
class { 'snoopy::install': }
class { 'snoopy::configure':
username => $user_name,
userid => $user_id,
groupid => $group_id,
superid => $super_id,
terminal => $terminal,
currentdirectory => $current_directory,
processid => $process_id,
filename => $file_name,
logfile => $log_file,
logpath => $log_path,
datetime => $date_time
}
}
This can bel closed, it is related to the version of puppet agent we are running. Module required version >= 4.0.0 and <= 6.0.0.
We are running 3.8.x.
I am using puppet-archive https://github.com/voxpupuli/puppet-archive to download jar from nexus repository.
/puppetmaster-devteam-starter_kit/control-repo/site/role/manifests/getnexusjar.pp
class role::getnexusjar {
include profile::getjarfromnexus
}
/puppetmaster-devteam-starter_kit/control-repo/site/profile/manifests/getjarfromnexus.pp
class profile::getjarfromnexus {
include '::archive'
$test_jar_dir = [ '/home/test/', '/home/test/jar/', ]
file { $test_jar_dir:
ensure => 'directory',
owner => 'root',
group => 'wheel',
mode => '0750',
}
archive::nexus { '/home/test/jar/test-fileprocess-workflow-1.0.0.jar':
ensure => present,
extract_path => '/home/test/jar',
url => 'https://nexus.testmonitoring.com/repository/test-repo/com/test/fileprocess/test-fileprocess-workflow/1.0.0/test-fileprocess-workflow-1.0.0.jar',
username => "testuser",
password => "asdfghfgh",
gav => 'com.test.fileprocess:test-fileprocess-workflow:1.0.0',
repository => 'test-repo',
packaging => 'jar',
extract => false,
}
}
Error:
Execution of '/usr/bin/curl https://nexus.testmonitoring.com/repository/test-repo/com/test/file/test-fileprocess-workflow/1.0.0/test-fileprocess-workflow-1.0.0.jar/service/local/artifact/maven/content?g=com.test.file&a=test-fileprocess-workflow&v=1.0.0&r=test-repo&p=jar -o /tmp/test-fileprocess-workflow-1.0.0.jar_20180118-30748-1j50ff9 -fsSL --max-redirs 5 --user testuser:asdfghfgh’ returned 35: curl: (35) Encountered end of file
I am trying to install a particular rpm using puppet, my init.pp is:
class nmap {
package {'nmap':
provider => 'rpm',
source => "<Local PATH to the RPM>",
}
}
and the rpm is in ...modules/nmap/files
If i move the rpm to manifests, and provide the rpm name in source => ''
class nmap {
package {'nmap':
provider => 'rpm',
source => "rpm-name.rpm",
}
}
it works, but how can i specify source path with ../files/ and do puppet apply successfully
When i use :
source => 'puppet:///files/nmap-6.45-1.x86_64.rpm',
i get an error:
Debug: Executing '/bin/rpm -i puppet:///files/nmap-6.45-1.x86_64.rpm'
Error: Execution of '/bin/rpm -i puppet:///files/nmap-6.45-1.x86_64.rpm' returned 1: error: open of puppet:///files/nmap-6.45-1.x86_64.rpm failed: No such file or directory
Error: /Stage[main]/Nmap/Package[nmap]/ensure: change from absent to present failed: Execution of '/bin/rpm -i puppet:///files/nmap-6.45-1.x86_64.rpm' returned 1: error: open of puppet:///files/nmap-6.45-1.x86_64.rpm failed: No such file or directory
`
when running the command:
sudo puppet apply --modulepath=/home/user1/qa/puppet_qa/modules/ -e "include nmap" --debug
Unlike the file resource type, the package type has no support for Puppet fileserver URLs. You will need to use a file resource to download the rpm prior to installing it. If this is a recurring problem for you, make a defined type that does those in one go (think macros), e.g.
define fileserver_package($source, $ensure='installed') {
file { "/my/tmp/dir/$name.rpm": source => $source }
package { $name:
ensure => $ensure,
provider => 'rpm',
source => "/my/tmp/dir/$name.rpm",
require => File["/my/tmp/dir/$name.rpm"],
}
}
Edit: it is generally advisable to use a local yum repo instead, see also the first comment by #rojs below.
The RPM package can be installed this way:
package { 'epel-release-6':
provider => 'rpm',
ensure => 'present',
source => '/usr/local/rpms/epel-release-latest-6.noarch.rpm',
}
It seems the module name you are using is nmap. You can use the same source parameter like this,
source => 'puppet:///modules/nmap/nmap-6.45-1.x86_64.rpm',
The syntax to access a file under a module goes like this,
puppet:///modules/<modulename>/<file you want to access>
See this link here, http://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html#files
Lets start from start :
on server:
$rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
$yum -y install puppetserver
$vi /etc/sysconfig/puppetserver #change JAVA args
$systemctl start puppetserver
$systemctl enable puppetserver
$vi /etc/puppetlabs/puppet/puppet.conf #Add “dns_alt_names” in [master]
On Agent:
$rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
$yum -y install puppet-agent
$systemctl start puppet
$systemctl enable puppet
$vi /etc/puppetlabs/puppet/puppet.conf # Add “server = pupmaster” in [main]
puppet cert list
puppet cert sign
/etc/puppetlabs/code/environments/production/manifests/site.pp:
node webserver {
class { 'apache': }
}
node dbserver {
class { ‘mysql’: }
}
mkdir –p /etc/puppetlabs/code/environments/production/modules/apache/{manifests, files}
apacheinstall.pp:
class apache::apacheinstall {
if $osfamily == 'redhat' {
package { 'httpd':
ensure => 'latest'
}
service {'httpd':
ensure => 'running',
require => Package["httpd"],
}
file { '/var/www/html/ndex.html':
mode => "0644",
owner => 'root',
group => 'root',
source => 'puppet:///modules/apache/index.html',
}
}
elsif $osfamily == 'debian' {
package { 'apache2':
ensure => 'latest'
}
service {'httpd':
ensure => 'running',
require => Package["httpd"],
}
}
}
INIT.pp
class apache {
notify { 'Installing and Configuring Webserver for $osfamily': }
include apache::mysqlinstall
}
Mysqlinstall.pp:
class apache::mysqlinstall {
exec { 'wget':
path => [ "/bin/", "/sbin/", "/usr/bin/", "/usr/sbin/" ],
command => "/usr/bin/wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm && rpm -ivh /tmp/mysql57-community-release-el7-9.noarch.rpm",
cwd => '/tmp/',
creates => '/etc/firstruns/p1.done',
}
}
A small puppet question
I am creating a composer project like so.
composer::project { 'project-test':
ensure => 'latest', #or installed?
target => '/home/test/www',
dev => false,
require => Package ['php', 'apache']
}
And then from an exec I want to require it as a resource. How can I?
Example of exec:
exec { 'generate-tests' :
command => 'php tests.php',
path => '/usr/bin/',
cwd => "/home/test/www/bin",
logoutput => 'true',
#require => composer::project['project-test']
}
Since what you're requiring is a resource, it should be capitalized as follows:
require => Composer::Project['project-test']