Ask Your Question
0

jira module - two pp files

asked 2015-05-18 13:02:22 -0600

pup-master gravatar image

updated 2015-05-21 17:24:36 -0600

So I have a single node name "jira.oracle" that I usually go with

These three are the pp codes I inherited and I'm struggling to get those working

[site.pp]

 node 'jira.oracle' { 
class {'jira':} 
}

[init.pp]

class jira (

  # Jira Settings
  $version      = '6.4.3',
  $product      = 'jira',
  $format       = 'tar.gz',
  $installdir   = '/opt/jira',
  $homedir      = '/opt/jira_home',
  $user         = 'jira',
  $group        = 'jira',

  # Database Settings
  $db           = 'mysql',
  $dbuser       = 'jira',
  $dbpassword   = 'secret',
  $dbserver     = 'localhost',
  $dbname       = 'jiraDB',
  $dbport       = '3306',
  $dbdriver     = 'com.mysql.jdbc.Driver',
  $dbtype       = 'mysql',
  $poolsize     = '20',

  # Configure database settings if you are pooling connections
  $enable_connection_pooling = false,
  $poolMinSize               = 20,
  $poolMaxSize               = 20,
  $poolMaxWait               = 30000,
  $validationQuery           = 'select 1',
  $minEvictableIdleTime      = 60000,
  $timeBetweenEvictionRuns   = 300000,
  $poolMaxIdle               = 20,
  $poolRemoveAbandoned       = true,
  $poolRemoveAbandonedTimout = 300,
  $poolTestWhileIdle         = true,
  $poolTestOnBorrow          = true,

  # JVM Settings
  $javahome     = '/usr/java/jdk1.8.0_45',
  $jvm_xms      = '4096m',
  $jvm_xmx      = '8192m',
  $jvm_optional = '-XX:-HeapDumpOnOutOfMemoryError',
  $java_opts    = '',

  # Misc Settings
  $downloadURL  = 'http://www.atlassian.com/software/jira/downloads/binary/',

  # Manage service
  $service_manage = true,
  $service_ensure = running,


) {

  if $jira::db != 'postgresql' and $jira::db != 'mysql' {
    fail('jira db parameter must be postgresql or mysql')
  }

  $webappdir    = "${installdir}/atlassian-${product}-${version}-standalone"
  $dburl        = "jdbc:${db}://${dbserver}:${dbport}/${dbname}"

  include jira::install
  include jira::config
  include jira::service

}

[install.pp]

   class jira::install {

  require jira
  require deploy

  user { $jira::user:
    comment          => 'Jira daemon account',
    shell            => '/bin/true',
    home             => $jira::homedir,
    password         => '*',
    password_min_age => '0',
    password_max_age => '99999',
    managehome       => true,
  } ->

  file { $jira::installdir:
    ensure  => 'directory',
    owner   => $jira::user,
    group   => $jira::group,
  }

  file { "/etc/cron.d/jira_mail_perms":
    mode    => 644,
    owner   => root,
    group   => root,
    source  => "puppet:///modules/jira/jira_mail_perms"
  }

  deploy::file { "atlassian-${jira::product}-${jira::version}.${jira::format}":
    target          => "${jira::installdir}/atlassian-${jira::product}-${jira::version}-standalone",
    url             => $jira::downloadURL,
    strip           => true,
    download_timout => 1800,
    owner           => $jira::user,
    group           => $jira::group,
    notify          => Exec["chown_${jira::webappdir}"],
  } ->

  file { $jira::homedir:
    ensure  => 'directory',
    owner   => $jira::user,
    group   => $jira::group,
  } ->

  file { "${jira::homedir}/import":
    ensure  => 'directory',
    mode    => 777
  } ->

  file { "${jira::homedir}/import/mail":
    ensure  => 'directory',
    mode    => 777
  } ->

  exec { "chown_${jira::webappdir}":
    command     => "/bin/chown -R ${jira::user}:${jira::group} ${jira::webappdir}",
    refreshonly => true,
    subscribe   => User[$jira::user]
  } ->

  file { "${jira::installdir}/atlassian-${jira::product}-${jira::version}-standalone/lib/mysql-connector-java-5.1.31-bin.jar":
    mode    => 644,
    owner   => root,
    group   => root,
    source  => "puppet:///modules/jira/mysql-connector-java-5.1.31-bin.jar"
  } ->

  file { "${jira::webappdir}/logs/old":
    ensure  => 'directory',
    owner   => $jira::user,
    group   => $jira::group,
  }

}

puppetmaster manifests]$ puppet parser validate install.pp
puppetmaster manifests]$ puppet parser validate site.pp
puppetmaster manifests]$ puppet parser validate init.pp
puppetmaster manifests]$

line 35 of /etc/puppet/environments/production/modules/jira/templates/context.xml.erb has

<% if ! scope.lookupvar('jira::resources').empty? -%>
<%   scope.lookupvar('jira::resources').each do |name, values| -%>

and more errors:

Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template jira/context.xml.erb:
  Filepath: /etc/puppet/environments/production/modules/jira/templates/context.xml.erb
  Line: 35
  Detail: undefined method `empty?' for nil:NilClass
 at /etc/puppet/environments/production/modules/jira/manifests/config.pp:71 on node jira.oracle
edit retag flag offensive close merge delete

Comments

The duplicate definition error is a result of the problem we were discussing in your other question about MySQL, I think. Is that correct? You are trying to manage the /etc/my.cnf file in 2 places, and Puppet does not allow that.

GregLarkin gravatar imageGregLarkin ( 2015-05-19 17:53:05 -0600 )edit

Hmm, how do I get the my.cnf without defining the mySQL class twice? Thank you for continuing help! really, wouldn't be getting this far alone.

pup-master gravatar imagepup-master ( 2015-05-19 20:33:46 -0600 )edit

Every class you "include" on a node is compiled into a single "catalog" that's delivered to the agent for enforcement. Puppet requires that in each catalog, a specified resource (file, user, etc.) is only managed once. Therefore, a file resource for /etc/my.cnf should only appear once in your code.

GregLarkin gravatar imageGregLarkin ( 2015-05-19 22:46:22 -0600 )edit

Ok then how do I do it? I've been struggling to set /etc/my.cnf appear only once. If I want to use the one already declared, how do I fit in my code? if I don't include it, config.pp doesn't put my.cnf. if I put it, then it's duplicate. I'm not very good at using modules at the moment.

pup-master gravatar imagepup-master ( 2015-05-20 12:37:58 -0600 )edit

Remove the file resource from /etc/puppet/environments/production/manifests/nodes.pp and let the mysql::server class manage the /etc/my.cnf for you.

GregLarkin gravatar imageGregLarkin ( 2015-05-20 12:44:40 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-05-18 17:03:16 -0600

GregLarkin gravatar image

updated 2015-05-18 17:35:55 -0600

What file and line number does the error complain about?

As I wrote in my answer to your other question, have a look at these documentation pages, and they should clear up where to put your node definitions vs. your class definitions:

https://docs.puppetlabs.com/puppet/latest/reference/langnodedefinitions.html https://docs.puppetlabs.com/puppet/3.8/reference/modules_fundamentals.html

UPDATE:

Modules are structured like so:

<moduledir>/
  <modulename>/
    manifests/
    files/
    templates/

For example, <moduledir> might be /etc/puppetlabs/puppet/modules, and <modulename> might be jira.

Template files (.erb) are located under the templates directory. In our example, the physical path to the template files would be /etc/puppetlabs/puppet/modules/jira/templates. If you then call the function template('jira/config.erb'), you will need to have a file located at /etc/puppetlabs/puppet/modules/jira/templates/config.erb, otherwise the catalog compiler will exit with an error.

edit flag offensive delete link more

Comments

thank you for your time

pup-master gravatar imagepup-master ( 2015-05-18 17:24:07 -0600 )edit

please check my updated post. How do I define where agents download the erb and other templates?

pup-master gravatar imagepup-master ( 2015-05-18 17:29:53 -0600 )edit

Using my example above, you need to make sure that your jira.erb file is placed correctly within the template directory of the jira module. You are using subdirs in the template function call, so that means you need to make an equivalent structure inside the templates directory.

GregLarkin gravatar imageGregLarkin ( 2015-05-18 17:44:42 -0600 )edit

You also have a problem in the jira::config class on line 71, but that appears to be something different. I suggest solving the first problem then moving on to the next one.

GregLarkin gravatar imageGregLarkin ( 2015-05-18 17:45:18 -0600 )edit

turns out files are all there under template. I changed the permission to a+rwx for all modules and subdirectoreis. But getting error I updated the post with.

pup-master gravatar imagepup-master ( 2015-05-18 17:53:34 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-05-18 13:02:22 -0600

Seen: 252 times

Last updated: May 21 '15