replacing a file with a symbolic link in a salt state

Viewed 4756

I'm new to salt-stack.

I'm trying to make sure a symbolic link exists.

/etc/localtime:
  file.symlink:
    - target: /usr/share/zoneinfo/Europe/Paris
    - file.exists:
      - name: /usr/share/zoneinfo/Europe/Paris

The result is as excepted when there's no existing /etc/localtime, or when /etc/localtime is already a symlink. But it fails when /etc/localtime is a regular file :

----------
State: - file
Name:      /etc/localtime
Function:  symlink
    Result:    False
    Comment:   File exists where the symlink /etc/localtime should be
    Changes:   

I can't figure how to code the state so the file is deleted before the link creation. Any clue ?

Cheers, Pierre

1 Answers
Related