Ask Your Question
0

Problem on virtual resource

asked 2016-07-04 08:54:06 -0600

Imagin0s gravatar image

updated 2016-07-04 16:22:28 -0600

lupin gravatar image

Hello,

I'm a bit new on puppet and I have some issues on realizing virtual resources. Here are my manifests below :

manifests/init.pp :

 class addmount ($list = undef,
 $default_nfs_options = undef,
 $default_cifs_options = undef  ) {

   file { "/etc/fstab":
         ensure => present,
         owner  => root,
         group  => root   }

   define addmount::mountpoint
 ($share_server, $share_name,
 $share_type, $share_mountoptions,
 $dumpandpass)   {

     file { "$name":
       ensure => 'directory',
     }

     if ($share_type == 'cifs' )
     {
       include addmount::mod::cifs_pack
       **realize(addmount::mod::cifs_pack:Package["${addmount::package_share_CIFS}"])**
       if ($share_mountoptions == false)
       {
         $share_mountoptions = "$addmount::default_cifs_options"
       }
       file_line
       { "${name}":
         path  => '/etc/fstab',
         line  => template('addmount/mount_CIFS.erb'),
         match => "//$share_server/$share_name.*$name.*"
       }
     }
     elsif ($share_type == 'nfs' )
     {
       include addmount::mod::nfs_pack
       realize(addmount::mod::nfs_pack:Package["${addmount::package_share_NFS}"])
       if ($share_mountoptions == false)
       {
         $share_mountoptions = "$addmount::default_nfs_options"
       }
       file_line
       { "${name}":
        path  => '/etc/fstab',
        line  => template('addmount/mount_NFS.erb'),
        match => "$share_server:/$share_name.*$name.*"
       }
    }

   }


 create_resources(addmount::mountpoint,hiera_hash('addmount::list'))

 }

manifests/mod/nfs_pack.pp :

class addmount::mod::nfs_pack
{
  @package { "${addmount::package_share_NFS}":
    ensure => present,
  }
}

manifests/mod/cifs_pack.pp :

class addmount::mod::cifs_pack
{
  @package { "${addmount::package_share_CIFS}":
    ensure => present,
  }
}

hieradata/nodes/ducrmde001.yaml

---
addmount::list:
  '/mnt/test':
    share_server: 'nashomologation.boursorama.fr'
    share_name: 'batch_middle/crmfr_dev'
    share_mountoptions: 'uid=800,gid=1006,dir_mode=0775,file_mode=0775,domain=boursorama.fr,username=batch,password=xxxxxx'
    dumpandpass: '0 0'
    share_type: cifs
  '/mnt/test2':
    share_server: 'nashomologation.boursorama.fr'
    share_name: 'batch_middle/crmde_dev'
    share_mountoptions: 'defaults'
    dumpandpass: '0 0'
    share_type: nfs
  '/mnt/test3':
    share_server: 'nashomologation.boursorama.fr'
    share_name: 'batch_middle/frmfr_dev'
    dumpandpass: '0 0'
    share_type: cifs

I've got the following error when I do puppet agent -t on the client :

ducrmde001 ~ :( #  puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at ':'; expected ')' at /etc/puppet/environments/staging/modules/addmount/manifests/init.pp:27 on node ducrmde001.boulogne.boursorama.fr
Warning: Not using cache on failed catalog

Error: Could not retrieve catalog; skipping run

(I have put line 27 of /etc/puppet/environments/staging/modules/addmount/manifests/init.pp in bold)

Have you got an idea ? I think it may be a syntax issue.

Regards,

edit retag flag offensive close merge delete

Comments

Seems the highlighted portion is lost during edit, can you please highlight it again.

lupin gravatar imagelupin ( 2016-07-04 16:32:12 -0600 )edit

Hello, I don't manage to highlight it. The line in error is : **realize(addmount::mod::cifs_pack:Package["${addmount::package_share_CIFS}"])** Thanks

Imagin0s gravatar imageImagin0s ( 2016-07-06 01:23:49 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-07-05 08:39:56 -0600

scoffland gravatar image

This is difficult to troubleshoot but I do see one syntax error on line 27 of addmount/manifests/init.pp as stated in the error message. Try the following change.

- file_line
- { "${name}":

+ file_line { "${name}":

You can check for syntax error with puppet parser validate <manifest>

edit flag offensive delete link more
0

answered 2016-07-06 01:37:42 -0600

Imagin0s gravatar image

updated 2016-07-06 05:26:17 -0600

Hello,

I have finally suceeded with the help of a coworker. I didn't resolve the issue, I just used an other method (without virtual resources), so the error message is not resolved yet for me. Here is the final code :

manifests/init.pp :

class addmount (
  $list = undef,
  $default_nfs_options = undef,
  $default_cifs_options = undef,
  $package_share_CIFS = undef,
  $package_share_NFS = undef,

  )
{

  file { "/etc/fstab":
        ensure => present,
        owner  => root,
        group  => root
  }

  define addmount::mountpoint ($share_server, $share_name, $share_type, $share_mountoptions, $dumpandpass, $toastGlobal = 'le monteur')
  {

    file { "$name":
      ensure => 'directory',
    }

    if ($share_type == 'cifs' )
    {
      include addmount::mod::cifs_pack
      if ($share_mountoptions == false)
      {
        $share_mountoptions_temp = "$addmount::default_cifs_options"
      }
      else
      {
        $share_mountoptions_temp = $share_mountoptions
      }
      file_line
      { "${name}":
        path  => '/etc/fstab',
        line  => template('addmount/mount_CIFS.erb'),
        match => "//$share_server/$share_name.*$name.*"
      }
    }
    elsif ($share_type == 'nfs' )
    {
      include addmount::mod::nfs_pack
      if ($share_mountoptions == false)
      {
        $share_mountoptions_temp = "$addmount::default_nfs_options"
      }
      else
      {
        $share_mountoptions_temp = $share_mountoptions
      }
      file_line
      { "${name}":
       path  => '/etc/fstab',
       line  => template('addmount/mount_NFS.erb'),
       match => "$share_server:/$share_name.*$name.*"
      }
    }

  }

  $default = {
    share_mountoptions => false,

  }


  create_resources(addmount::mountpoint,hiera_hash('addmount::list'),$default)

}

mod/cifs_pack.pp :

class addmount::mod::cifs_pack
{
  package { "${addmount::package_share_CIFS}":
    ensure => present,
  }
}

mod/nfs_pack.pp :

class addmount::mod::nfs_pack
{
  package { "${addmount::package_share_NFS}":
    ensure => present,
  }
}

You are free to comment if you found the reason why it didn't work in a first time.

Thanks.

edit flag offensive delete link more

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: 2016-07-04 08:54:06 -0600

Seen: 254 times

Last updated: Jul 06 '16