FAQ
Hi,

I'm trying to use puppet to move some folders from one directory to another
in Windows.

That being said I have a parameterized define which looks like that:

define module_name::move ($dir_name, $arg2){

$dir_origin = "c:/${dir_name}"
$dir_destination = "c:/tmp/${arg2}"

file { $dir_destination:
ensure => 'directory',
mode => '755',
}

exec { $backup_folder :
command => "cmd.exe /c move $dir_origin $dir_destination",
path => 'c:\windows\system32;c:\windows',
}
}


and I call the define as follow:
module_name::move { 'folder_name':
dir_name => ['dir1','dir2','dir3'],
arg2 => blah,
}


when I execute this code, puppet concatenate the value of $dir_name as
dir1dir2dir3 instead of running my define 3 separate times.

I would greatly appreciate getting some help on how I could reach my
purpose.

Thanks,
Mike

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/j8s4ytdFlk0J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • David Schmitt at Nov 19, 2012 at 11:22 am
    You are passing an array (dir_name) into a single resource. Instead you
    want to create three separate resources:

    module_name::move { [ dir1, dir2, dir3 ]: ... }


    Also, I feel compelled to point out that having verbs or actions as names
    of resources is a big red warning flag, that you're doing something outside
    the intended design of puppet. e.g. are you aware that your define will try
    to move the directories every time you run the agent with this?



    Best Regards, David

    On Sun, 18 Nov 2012 23:14:29 -0800 (PST), mickael avedissian
    wrote:
    Hi,

    I'm trying to use puppet to move some folders from one directory to
    another
    in Windows.

    That being said I have a parameterized define which looks like that:

    define module_name::move ($dir_name, $arg2){

    $dir_origin = "c:/${dir_name}"
    $dir_destination = "c:/tmp/${arg2}"

    file { $dir_destination:
    ensure => 'directory',
    mode => '755',
    }

    exec { $backup_folder :
    command => "cmd.exe /c move $dir_origin $dir_destination",
    path => 'c:\windows\system32;c:\windows',
    }
    }


    and I call the define as follow:
    module_name::move { 'folder_name':
    dir_name => ['dir1','dir2','dir3'],
    arg2 => blah,
    }


    when I execute this code, puppet concatenate the value of $dir_name as
    dir1dir2dir3 instead of running my define 3 separate times.

    I would greatly appreciate getting some help on how I could reach my
    purpose.

    Thanks,
    Mike
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Mickael avedissian at Nov 19, 2012 at 3:22 pm
    Thank you for your answer Dave.

    This is the intended purpose of having the puppet agent move those folders
    every time it is called.

    Would it be an easier (more proper) way of doing it?

    Thanks,
    Mike
    On Monday, November 19, 2012 6:22:55 AM UTC-5, David Schmitt wrote:


    You are passing an array (dir_name) into a single resource. Instead you
    want to create three separate resources:

    module_name::move { [ dir1, dir2, dir3 ]: ... }


    Also, I feel compelled to point out that having verbs or actions as names
    of resources is a big red warning flag, that you're doing something
    outside
    the intended design of puppet. e.g. are you aware that your define will
    try
    to move the directories every time you run the agent with this?



    Best Regards, David

    On Sun, 18 Nov 2012 23:14:29 -0800 (PST), mickael avedissian
    <xli...@gmail.com <javascript:>> wrote:
    Hi,

    I'm trying to use puppet to move some folders from one directory to
    another
    in Windows.

    That being said I have a parameterized define which looks like that:

    define module_name::move ($dir_name, $arg2){

    $dir_origin = "c:/${dir_name}"
    $dir_destination = "c:/tmp/${arg2}"

    file { $dir_destination:
    ensure => 'directory',
    mode => '755',
    }

    exec { $backup_folder :
    command => "cmd.exe /c move $dir_origin $dir_destination",
    path => 'c:\windows\system32;c:\windows',
    }
    }


    and I call the define as follow:
    module_name::move { 'folder_name':
    dir_name => ['dir1','dir2','dir3'],
    arg2 => blah,
    }


    when I execute this code, puppet concatenate the value of $dir_name as
    dir1dir2dir3 instead of running my define 3 separate times.

    I would greatly appreciate getting some help on how I could reach my
    purpose.

    Thanks,
    Mike
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/pP7RbRfgngIJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • David Schmitt at Nov 19, 2012 at 5:02 pm

    On 2012-11-19 16:22, mickael avedissian wrote:
    Thank you for your answer Dave.

    This is the intended purpose of having the puppet agent move those
    folders every time it is called.

    Would it be an easier (more proper) way of doing it?

    Without knowing your actual requirements, a possible solution might
    involve adding a scheduler task that will move the directories every 30
    minutes. This would be much more explicit than "whenever puppet is
    running", which might be much more often (when
    developing/testing/deploying) or much longer (when there's a problem on
    the puppet master for example).


    Best Regards, David (not Dave).


    Thanks,
    Mike

    On Monday, November 19, 2012 6:22:55 AM UTC-5, David Schmitt wrote:


    You are passing an array (dir_name) into a single resource. Instead you
    want to create three separate resources:

    module_name::move { [ dir1, dir2, dir3 ]: ... }


    Also, I feel compelled to point out that having verbs or actions as
    names
    of resources is a big red warning flag, that you're doing something
    outside
    the intended design of puppet. e.g. are you aware that your define
    will try
    to move the directories every time you run the agent with this?



    Best Regards, David

    On Sun, 18 Nov 2012 23:14:29 -0800 (PST), mickael avedissian
    <xli...@gmail.com <javascript:>> wrote:
    Hi,

    I'm trying to use puppet to move some folders from one directory to
    another
    in Windows.

    That being said I have a parameterized define which looks like that:

    define module_name::move ($dir_name, $arg2){

    $dir_origin = "c:/${dir_name}"
    $dir_destination = "c:/tmp/${arg2}"

    file { $dir_destination:
    ensure => 'directory',
    mode => '755',
    }

    exec { $backup_folder :
    command => "cmd.exe /c move $dir_origin $dir_destination",
    path => 'c:\windows\system32;c:\windows',
    }
    }


    and I call the define as follow:
    module_name::move { 'folder_name':
    dir_name => ['dir1','dir2','dir3'],
    arg2 => blah,
    }


    when I execute this code, puppet concatenate the value of
    $dir_name as
    dir1dir2dir3 instead of running my define 3 separate times.

    I would greatly appreciate getting some help on how I could reach my
    purpose.

    Thanks,
    Mike
    --
    You received this message because you are subscribed to the Google
    Groups "Puppet Users" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/puppet-users/-/pP7RbRfgngIJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedNov 19, '12 at 7:14a
activeNov 19, '12 at 5:02p
posts4
users2
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase