0
votes

I'm currently having trouble getting my module to work.

My goal here is to have a script that will add a repository to install brackets, install puppet, and copy an existing module

finaldigi/manifests/init.pp ---->>> /etc/puppet/modules folder

For some reason, the module works if I do all the script commands manually, but when I put them in a script and run it, it shows this error:

Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class packagemodule at line 1 on node xubuntu.dhcp.inet.fi

Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class packagemodule at line 1 on node xubuntu.dhcp.inet.fi

Here is my init.pp file

class packagemodule {

       package { brackets:
               ensure => 'installed',
               allowcdrom => 'true',
       }

       package { apache2:
             ensure => 'installed',
             allowcdrom => 'true',
       }

       file {'/var/www/html/index.html':
             content => "testing testing",
       }
    }

And my script:

#!/bin/bash
echo | sudo add-apt-repository ppa:webupd8team/brackets
sudo apt-get update
sudo apt-get install -y puppet
sudo cp -r ./finaldigi /etc/puppet/modules
sudo puppet apply -e 'class {packagemodule:}'

So yeah, it DOES work and won't show any errors if I type all the commands MANUALLY, but if I start putting all those commands in my bash script, it doesn't work and starts showing that error.

What am I missing here?

1

1 Answers

0
votes
 sudo cp -r ./finaldigi /etc/puppet/modules

This will create /etc/puppet/modules/finaldigi and /etc/puppet/modules/finaldigi/manifests/init.pp, but the directory should be called packagemodule if that's the class name you're using inside.

Change this to:

 sudo cp -r ./finaldigi /etc/puppet/modules/packagemodule

(If this doesn't work, please provide a find /etc/puppet/modules output, provide the Puppet version you're using, and output of puppet apply --configprint modulepath)