Search code examples
tomcatpuppet

Puppet - Syntax error at 'unpack_tomcat'; expected '}'


i tried to deploy tomcat to the node1 agent

node default {

include lamp

}
node "node1.puppet" {

include tomcat

}

site.pp

    ├── auth.conf
├── fileserver.conf
├── manifests
│   └── site.pp
├── modules
│   ├── ftp
│   │   ├── files
│   │   │   └── vsftpd.conf
│   │   ├── lib
│   │   └── manifests
│   │       └── init.pp
│   ├── lamp
│   │   ├── lib
│   │   └── manifests
│   │       └── init.pp
│   ├── tomcat
│   │   ├── files
│   │   │   ├── apache-tomcat-8.0.17.zip
│   │   │   ├── script.sh
│   │   │   └── wgetrc
│   │   ├── lib
│   │   └── manifests
│   │       └── init.pp
│   └── unzip
│       └── manifests
│           └── init.pp
└── puppet.conf

my file structure..

and the content of the /modules/tomcat/manifests/init.pp

class tomcat {
        exec { "open_ports":
                command => "/bin/firewall-cmd --zone=public --add-port=8080/tcp --permanent",
        }
        exec { "reload_firewall":
                command => "/bin/firewall-cmd --reload",
                require => Exec["open_ports"],
        }
        if $operatingsystem == "centos" {
                file { "/etc/wgetrc":
                        owner => root,
                        group => root,
                        mode => 640,
                        source => "puppet:///modules/tomcat/wgetrc",
                }
        }
        file { "/opt/apache-tomcat-8.0.17.zip":
                owner => root,
                group => root,
                mode => 640,
                source => "puppet:///modules/tomcat/apache-tomcat-8.0.17.zip,
        }
        exec { "unpack_tomcat":
                command => "/usr/bin/unzip apache-tomcat-8.0.17,
                cwd => "/opt",
                require => File["/opt/apache-tomcat-8.0.17"],}

 exec { "create_directorys":
                command => "/bin/mkdir -p /opt/apache-tomcat-8.0.17/instances/original/{lib,work,temp,logs,webapps,bin},
                require => Exec["create_directorys"],
        }
}

I tried everything and i cant find a mistake.. What did i do wrong?

The error message, after pulling the catalog from the master..

    [root@node1 puppet]# puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at 'unpack_tomcat'; expected '}' at /etc/puppet/modules/tomcat/manifests/init.pp:23 on node node1.puppet
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Thanks in advance! :)

Update:

Got it! The mistake was in the init.pp file!

Here is the new one:

class tomcat {
        exec { "open_ports":
                command => "/bin/firewall-cmd --zone=public --add-port=8080/tcp --permanent",
        }
        exec { "reload_firewall":
                command => "/bin/firewall-cmd --reload",
                require => Exec["open_ports"],
        }
        if $operatingsystem == "centos" {
                file { "/etc/wgetrc":
                        owner => root,
                        group => root,
                        mode => 640,
                        source => "puppet:///modules/tomcat/wgetrc",
                }
        }
        file { "copy_tomcat":
                owner => root,
                group => root,
                mode => 640,
                path => "/opt/apache-tomcat-8.0.17.zip",
                source => "puppet:///modules/tomcat/apache-tomcat-8.0.17.zip",
        }
        exec { "unpack_tomcat":
                command => "/usr/bin/unzip apache-tomcat-8.0.17.zip",
                cwd => "/opt",
                require => File["copy_tomcat"],
        }

        exec { "create_directorys":
                command => "/bin/mkdir -p /opt/apache-tomcat-8.0.17/instances/original/{lib,work,temp,logs,webapps,bin}",
                require => Exec["unpack_tomcat"],
        }
}

Solution

  • there is a " missed in this line

    source => "puppet:///modules/tomcat/apache-tomcat-8.0.17.zip,
    

    and same problem in these lines

    command => "/usr/bin/unzip apache-tomcat-8.0.17,
    
    command => "/bin/mkdir -p /opt/apache-tomcat-8.0.17/instances/original/{lib,work,temp,logs,webapps,bin},