Ask Your Question

unable to copy file with source attribute

asked 2015-05-17 12:04:44 -0600

Chutki gravatar image

I have written test manifest for source attribute, below is the one

file { '/tmp/testfile/testsource':
ensure => present,
source => '/tmp/copyfile/aa'

aa is the file that I wanna copy it to /testsource file location, both ( /tmp/testfile/testsource and /tmp/copyfile/aa) are present in agent.

testsource file is created but unable to copy aa file to /tmp/testfile/testsource location.

I am not sure, what blunder I did.

Could someone help me.

edit retag flag offensive close merge delete


Copy the `file {…}` resource above into a temporary file on the agent node, then, as root, run `puppet apply --test /path/to/temporary/file.pp` and add the results to your question?

JohnsonEarls gravatar imageJohnsonEarls ( 2015-05-17 14:11:13 -0600 )edit

yes I wrote below manifests testfile.pp class testfile { file { '/tmp/testfile/testsource': ensure => present, source => '/tmp/copyfile/aa' } include tesfile and ran "puppet agent -t /etc/puppetlabs/puppet/modules/tesfile.pp" but I didn't get any o/p

Chutki gravatar imageChutki ( 2015-05-17 20:21:09 -0600 )edit

Run puppet apply --test /etc/puppetlabs/puppet/modules/testfile.pp -- apply, not agent.

JohnsonEarls gravatar imageJohnsonEarls ( 2015-05-17 20:38:58 -0600 )edit

"Notice: Compiled catalog for in environment production in 0.18 seconds Info: Applying configuration version '1431920048' Notice: Finished catalog run in 0.82 seconds" This is the message I got it

Chutki gravatar imageChutki ( 2015-05-17 22:35:36 -0600 )edit

wait - is /tmp/testfile/testsource a directory or a file?

JohnsonEarls gravatar imageJohnsonEarls ( 2015-05-18 09:30:16 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-05-18 12:07:18 -0600

JohnsonEarls gravatar image
file { '/tmp/testfile/testsource':
    ensure => directory,
    source => '/tmp/copyfile/aa',
    recurse => yes

if you want to delete files from /tmp/testfile/testsource that do not exist in /tmp/copyfile/aa then also include

    purge => yes
edit flag offensive delete link more


Thank you :) what would be the case if want to delete file that exist from source(/tmp/copyfile/aa) to target (/tmp/testfile/testsource)

Chutki gravatar imageChutki ( 2015-05-18 12:24:43 -0600 )edit

Do you mean that you want files _moved_ from /tmp/copyfile/aa to /tmp/testfile/testsource rather than _copied_ ?

JohnsonEarls gravatar imageJohnsonEarls ( 2015-05-18 13:07:49 -0600 )edit

No not required to move, you updated by using "pure" attribute we can delete file which doesn't exist in "source" attribute, so wanna know is there any attribute or options available if the file exists in source that should be deleted.

Chutki gravatar imageChutki ( 2015-05-18 19:41:58 -0600 )edit

The file resource will never affect the source, only the target.

JohnsonEarls gravatar imageJohnsonEarls ( 2015-05-18 20:20:52 -0600 )edit

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


Asked: 2015-05-17 12:04:44 -0600

Seen: 469 times

Last updated: May 18 '15