Starting with salt -- hello world

546 views
Skip to first unread message

Jeff Abrahamson

unread,
Jan 12, 2018, 8:38:05 AM1/12/18
to salt-...@googlegroups.com

I'm trying to get started with salt after lots of reading of docs.  I'm clearly missing something.  The goal at the moment is to get a minimal masterless example running to convince myself that I can do anything.  I'm doing this on a vagrant instance.  Once I have this working, I'll convince myself I can deploy to a real (linode vps) host.  Once that's working, the plan is to start using a salt master.  One thing at a time.  I'm moving our infra from puppet, so the plan is to move responsibilities one at a time from puppet to salt.

Let's start by creating a file.

In both /etc/salt/{master,minion}, I've added these lines:

    file_roots:
      base:
    - /srv/salt


And I have created these files:

    ubuntu@tyne1:~$ find /srv
    /srv
    /srv/salt
    /srv/salt/jeff
    /srv/salt/jeff/jeff
    /srv/salt/jeff/init.cls
    /srv/salt/top.cls
    ubuntu@tyne1:~$

== top.cls ==
base:
  '*':
    - jeff


== jeff/init.cls ==
/tmp/jeff:
  file.managed:
    - source: salt://jeff/jeff
    - user: ubuntu
    - group: ubuntu
    - mode: 400

== jeff/jeff ==
Hello, world!

So now I'd like to get salt to create that little file in /tmp/.

ubuntu@tyne1:~$ sudo salt-call --local state.apply -l debug
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: xxxxx
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Determining pillar cache
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded state.apply
[DEBUG   ] LazyLoaded grains.get
[DEBUG   ] LazyLoaded saltutil.is_running
[DEBUG   ] LazyLoaded roots.envs
[DEBUG   ] Could not LazyLoad roots.init: 'roots.init' is not available.
[DEBUG   ] Updating roots fileserver cache
[INFO    ] Loading fresh modules for state activity
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] Could not find file 'salt://top.sls' in saltenv 'base'
[DEBUG   ] No contents loaded for env: base
[DEBUG   ] No contents found in top file. If this is not expected, verify that the 'file_roots' specified in 'etc/master' are accessible. The 'file_roots' configuration is: {'base': ['/srv/salt']}
[DEBUG   ] LazyLoaded config.option
[DEBUG   ] LazyLoaded highstate.output
local:
----------
          ID: states
    Function: no.None
      Result: False
     Comment: No Top file or master_tops data matches found.
     Changes:  

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   0.000 ms
ubuntu@tyne1:~$


Any pointers to what I'm missing or not understanding?

-- 

Jeff Abrahamson
+33 6 24 40 01 57
+44 7920 594 255

http://p27.eu/jeff/

Dafydd Jones (techneg.it)

unread,
Jan 12, 2018, 9:25:03 AM1/12/18
to salt-...@googlegroups.com
Hi Jeff,

state files are .sls not .cls

Dafydd

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/4785692a-5363-2cfa-55b0-e8be345e6924%40p27.eu.
For more options, visit https://groups.google.com/d/optout.

Joel Whitehouse

unread,
Jan 12, 2018, 12:35:24 PM1/12/18
to salt-...@googlegroups.com

Jeff,

Welcome to saltstack! I like your approach of beginning with salt
masterless, the gradually refactoring your setup into saltstack; I
started the same way!

As for your issue, I noticed a typo in your file names:

On 01/12/2018 04:46 AM, Jeff Abrahamson wrote:

> /srv/salt/jeff/init.cls
> /srv/salt/top.cls

You're using the '.cls' extension; salt will be looking for '.sls' as
you can see in the output:

> [DEBUG ] Could not find file 'salt://top.sls' in saltenv 'base'


Hope this helps. Happy Friday!

-Joel

Jeff Abrahamson

unread,
Jan 12, 2018, 12:47:08 PM1/12/18
to Joel Whitehouse, salt-...@googlegroups.com
On 12/01/18 18:11, Joel Whitehouse wrote:
> Jeff,
>
> Welcome to saltstack!  I like your approach of beginning with salt
> masterless, the gradually refactoring your setup into saltstack; I
> started the same way!

Thanks for the validation on that one, the near absence of that advice
in the docs and blogs has had me worried that I was really confused.


> As for your issue, I noticed a typo in your file names:
>
> On 01/12/2018 04:46 AM, Jeff Abrahamson wrote:
>
>>      /srv/salt/jeff/init.cls
>>      /srv/salt/top.cls
>
> You're using the '.cls' extension; salt will be looking for '.sls' as
> you can see in the output:
>
>> [DEBUG   ] Could not find file 'salt://top.sls' in saltenv 'base'

D'oh!  Thanks!  That also sorts out the problem that emacs keeps
thinking that latex mode would be appropriate. ;-)
Reply all
Reply to author
Forward
0 new messages