Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file: force_unlink and manage_link_source don't work #4992

Open
jaymzh opened this issue Jun 3, 2016 · 4 comments
Open

file: force_unlink and manage_link_source don't work #4992

jaymzh opened this issue Jun 3, 2016 · 4 comments
Labels

Comments

@jaymzh
Copy link
Collaborator

jaymzh commented Jun 3, 2016

Description

setup the test:

echo 'foo' > /tmp/foo
ln -s /tmp/foo /tmp/link

Sample recipe:

$ cat /tmp/test.rb
file '/tmp/link' do
  force_unlink true
  content 'fuckidy'
end

Try it:

[phild@dev8344 tmp]$ chef-apply /tmp/test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * file[/tmp/link] action create[2016-06-03T06:27:18-07:00] WARN: File /tmp/link managed by file[/tmp/link] is really a symlink. Managing the source file instead.
[2016-06-03T06:27:18-07:00] WARN: Disable this warning by setting `manage_symlink_source true` on the resource
[2016-06-03T06:27:18-07:00] WARN: In a future Chef release, 'manage_symlink_source' will not be enabled by default

    - update content in file /tmp/link from b5bb9d to 2f7925
    --- /tmp/link   2016-06-03 06:26:47.705361719 -0700
    +++ /tmp/.link20160603-2039507-1qjlpa5  2016-06-03 06:27:18.526023383 -0700
    @@ -1,2 +1,2 @@
    -foo
    +fuckidy
    - restore selinux security context

What did it do?

$ ls -l /tmp/link
lrwxrwxrwx. 1 phild users 8 Jun  3 06:25 /tmp/link -> /tmp/foo

Nope still a link. OK, so what about if we tell it to manage symlink sources while we're at it?

$ cat /tmp/test.rb 
file '/tmp/link' do
  force_unlink true
  manage_symlink_source true
  content 'fuckidy'
end
$ chef-apply /tmp/test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * file[/tmp/link] action create
    - update content in file /tmp/link from b5bb9d to 2f7925
    --- /tmp/link   2016-06-03 06:29:10.992437914 -0700
    +++ /tmp/.link20160603-2044816-v4dg9o   2016-06-03 06:29:17.541578521 -0700
    @@ -1,2 +1,2 @@
    -foo
    +fuckidy
    - restore selinux security context

did that do it?

[phild@dev8344 tmp]$ ls -l /tmp/link
lrwxrwxrwx. 1 phild users 8 Jun  3 06:25 /tmp/link -> /tmp/foo

Nope.

Chef Version

12.6.0

Platform Version

CentOS 6 and 7

Replication Case

see above

Client Output

See above.

@jaymzh jaymzh added Bug labels Jun 3, 2016
@smurawski smurawski added this to the Accepted Minor milestone Jun 8, 2016
@thommay thommay added Type: Bug Does not work as expected. Priority: Low and removed Bug labels Jan 25, 2017
@jakauppila
Copy link
Contributor

I was running into this as well but found that if I configure both force_unlink true and manage_symlink_source false it would actually unlink the target file.

With only force_unlink true it was modifying the source file itself.

@lamont-granquist lamont-granquist removed this from the Accepted Minor milestone Oct 14, 2019
@jakauppila
Copy link
Contributor

Just wanted to leave a note that I am still running into this on 16.9.17

@liaden
Copy link

liaden commented Jan 18, 2021

I once uninstalled ruby from all our VMs by accident with this bug, and the only reason it didn't cause an outage was because we hadn't attempted to restart any processes yet.

I tried to have it unlink a symlink and then create a file in its place to do some magic. It didn't unlink, and then it overwrote the linked file.

@tas50 tas50 changed the title [file resource] force_unlink and manage_link_source don't work file: force_unlink and manage_link_source don't work May 6, 2021
@jaymzh
Copy link
Collaborator Author

jaymzh commented Jan 20, 2024

@johnmccrae - are you sure this is fixed?

@jaymzh jaymzh reopened this Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants