Ask Your Question
0

unable to copy file with source attribute

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

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

Comments

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 -0500 )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 -0500 )edit

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

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

"Notice: Compiled catalog for server.puppet.com 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 -0500 )edit

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

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

1 Answer

Sort by » oldest newest most voted
0

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

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

Comments

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 -0500 )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 -0500 )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 -0500 )edit

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

JohnsonEarls gravatar imageJohnsonEarls ( 2015-05-18 20:20:52 -0500 )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

Stats

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

Seen: 380 times

Last updated: May 18 '15