SaltStack is not copying a directory with subdirectories and files

1,460 views
Skip to first unread message

Thorsten Michels

unread,
Sep 25, 2015, 5:38:42 AM9/25/15
to Salt-users
Hi there!
I am new to SaltStack and either I am asking a stupid question or was searching for the wrong things.

In my "LAB" down in the cellar, I have 12 Servers of different size and hardware, but all are running the very same Ubuntu 14.04.3 LTS. (Installed from the very same DVD)
- 5 PCs: 4 GB RAM, AMD Semperon 3300+, 80 GB HDD                                                     (DC1_Rack1_[12345])
- 4 PCs: 8 GB RAM, AMD Semperon 3600+, 80 GB HDD                                                     (DC2_Rack3_[6789])
- 1 Dell 2950: 32 GB RAM, 2 Xeon 5130, 2 x 200 GB HDD                                                   (DC4_Rack5_1)
- 1 Dell SC 1435, 32 GB RAM, 2 Xeon 5320, 1 x 500 GB HDD                                             (DC4_Rack5_2)
- 1 Fujitsu Siemens RX 360, 144 GB RAM, 2 Xeon 5530, 5 x 1 TB HDD (Raid 5) (Node12) (DC4_Rack5_3)

One of the 5 PCs (aka "DC1_Rack1_1") is my SaltStack master. On this I have my Mesos 0.24.0 binaries (/var/tmp/mesos/build), that I want to distribute to all (!) other servers.

And here is the jumping comma:
How can I copy these bunch of files (stored in some subdirectories) to the desired /usr/bin/mesos directory?
I tried file.copy, but could not get it to work, the same with file.managed. Both in both ways, as command on CLI and as sls-file. Nothing worked.
Well, at least not as expected.

tmichels@DC1_Rack1_1:/srv/salt$ sudo salt '*' --version
salt 2015.5.3 (Lithium)

tmichels@
DC1_Rack1_1:/srv/salt$ cat mesos.sls
copy_mesos:

  file.copy:
    - name: /usr/bin/mesos
    - source:
      - salt://var/tmp/mesos/build
    - force: True
    - recurse: True
    - makedirs: True
    - preserve: True
    - user: tmichels
    - group: tmichels
    - mode: 755

The error I get is:
tmichels@
DC1_Rack1_1:/srv/salt$ sudo salt 'DC1_Rack1_2' state.sls mesos
DZ1_Rack1_2:
----------
          ID: sync mesos
    Function: file.copy
        Name: /var/tmp/mesos
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1560, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/states/file.py", line 3513, in copy
                  source = os.path.expanduser(source)
                File "/usr/lib/python2.7/posixpath.py", line 261, in expanduser
                  if not path.startswith('~'):
              AttributeError: 'list' object has no attribute 'startswith'
     Started: 11:32:44.609036
    Duration: 5.802 ms
     Changes:

Summary
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1

tmichels@
DC1_Rack1_1:/srv/salt$ cat master
file_roots:
  base:
    - /srv/salt
    - /var/tmp/mesos
    - /var/tmp/mesos/build

Maybe I am using the wrong command or in a wrong way? Or am I missing a detail? ...???

Any support or hint is very appreciated.



Thank you very much in advance.

Cheers
Thorsten

Aled Jones

unread,
Sep 25, 2015, 9:29:57 AM9/25/15
to salt-users
Hello,
Perhaps try file.recurse instead...

/usr/bin/mesos:
  file.recurse:
    - source: salt://var/tmp/mesos/build




--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thorsten Michels

unread,
Sep 25, 2015, 12:42:04 PM9/25/15
to Salt-users
Hi Aled!

Thanks for the quick reply.

I tried your suggestion:
tmichels@Node1:/srv/salt$ cat testmesos.sls

/usr/bin/mesos:
  file.recurse:
    - source: salt://var/tmp/mesos/build
-----------

tmichels@Node1:/srv/salt$ sudo salt 'DC1_Rack1_2' state.sls testmesos
DC1_Rack1_2:
----------
          ID: /usr/bin/mesos
    Function: file.recurse
      Result: False
     Comment: Recurse failed: none of the specified sources were found
     Started: 18:37:05.040253
    Duration: 22.038 ms

     Changes:

Summary
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1

Unfortunately this is not the desired solution either. :-(

Or did I do something wrong?

Nicholas Capo

unread,
Sep 25, 2015, 12:49:44 PM9/25/15
to Salt-users

A salt:// URL is rooted in file_roots (see master.conf).

By default this is /srv/salt, so salt://foo/bar maps to /srv/salt/foo/bar.

Basicly you will need to put your mesos files under /srv/salt

Also take a look at the documentation for file.recurse:
https://docs.saltstack.com/en/develop/ref/states/all/salt.states.file.html#salt.states.file.recurse

Nicholas


--
Reply all
Reply to author
Forward
0 new messages