Unable to copy full content of directory in multiple location.

28 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Pratip Ghosh

ungelesen,
20.03.2017, 11:09:4820.03.17
an Puppet Users
Hi,

I am facing following error to copy full content of directory in multiple location.

Error: Failed to apply catalog: Parameter command failed on Exec[copy]: Command must be a String, got value of class Array at /etc/puppet/modules/wordpress/manifests/wp.pp:23


wp.pp
=====
class wordpress::wp {

    # Copy the Wordpress bundle to /tmp
    file { '/tmp/latest.tar.gz':
        ensure => present,
        source => "puppet:///modules/wordpress/latest.tar.gz"
    }

    # Extract the Wordpress bundle
    exec { 'extract':
        cwd => "/tmp",
        command => "tar -xvzf latest.tar.gz",
        require => File['/tmp/latest.tar.gz'],
        path => ['/bin'],
    }

    # Copy to /var/www/abc_com

    exec { 'copy':
        command => ["cp -r /tmp/wordpress/* /var/www/abc_com","cp -r /tmp/wordpress/* /var/www/xyz_com"],
        require => Exec['extract'],
        path => ['/bin'],
    }


    # Generate the wp-config.php file using the template for abc.com
    file { '/var/www/abc_com/wp-config.php':
        ensure => present,
        require => Exec['copy'],
        content => template("wordpress/wp-config.php.abc")
    }

    file { '/var/www/xyz_com/wp-config.php':
        ensure => present,
        require => Exec['copy'],
        content => template("wordpress/wp-config.php.xyz")
    }

}

jcbollinger

ungelesen,
21.03.2017, 09:02:3921.03.17
an Puppet Users


On Monday, March 20, 2017 at 10:09:48 AM UTC-5, Pratip Ghosh wrote:
Hi,

I am facing following error to copy full content of directory in multiple location.

Error: Failed to apply catalog: Parameter command failed on Exec[copy]: Command must be a String, got value of class Array at /etc/puppet/modules/wordpress/manifests/wp.pp:23


So what's your confusion?  This is about the clearest error message you could hope for.  Puppet complains that it requires the 'command' parameters of Exec resources to be strings, but that that parameter of the Exec resource entitled 'copy' is instead an array.  It even provides the line number in your manifest, and the parameter's assigned value indeed is an array:
 
    exec { 'copy':
        command => ["cp -r /tmp/wordpress/* /var/www/abc_com","cp -r /tmp/wordpress/* /var/www/xyz_com"],
        require => Exec['extract'],
        path => ['/bin'],
    }

If you want to execute two separate `cp` commands, then you have several options; among the best are:
  • Split them into two Exec resources
  • Join them into a single string via a semicolon, and add provider => 'shell' to the Exec's parameters
  • Create a script containing the commands, ensure it present on the target machine, and execute the script vie an Exec resource

John

Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten