HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

SaltStack and Vagrant adding files

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
vagrantsaltstackaddingfilesand

Problem

I use file.managed to add a file:

/home/vagrant/.bash_profile:
  file.append:
    - name: /home/vagrant/.bash_profile
    - source: salt://config/user/.bash_profile
    - user: vagrant
    - group: vagrant
    - template: jinja
    - mode: 0775
    - replace: true


The file is added; however the file is owned by root/root and does not change to by owned by vagrant.

Using Vagrant 1.8.5.
Salt is configured to be masterless and file client is local.

Solution

You aren't actually using file.managed, you are using file.append - so salt is expecting to add onto the end of an existing file. This may be the cause of your issue. Instead try:

/home/vagrant/.bash_profile:
  file.managed:
    - name: /home/vagrant/.bash_profile
    - source: salt://config/user/.bash_profile
    - mode: 0775
    - user: vagrant
    - group: vagrant
    - template: jinja
    - replace: true


Also, be sure you are using the latest version of Salt Stack, 2016.11

Code Snippets

/home/vagrant/.bash_profile:
  file.managed:
    - name: /home/vagrant/.bash_profile
    - source: salt://config/user/.bash_profile
    - mode: 0775
    - user: vagrant
    - group: vagrant
    - template: jinja
    - replace: true

Context

StackExchange DevOps Q#1243, answer score: 1

Revisions (0)

No revisions yet.