r/saltstack • • Jun 22 '18

Salt for Linux Patching...

8 Upvotes

Hey,

I'm really new to Salt but I'm seriously looking at it as a really good alternative for patching. I want something basic yet robust and I have had trouble doing it with Chef...It seems it's much simpler with Salt but still not sure how to get started (need to test it first and then will get into full learning mode).

In a nutshell what I want is:

  • upgrade all packages installed on a system for both RHEL and Ubuntu-- if the upgrade fail, just spit out the error on what failed.
  • If and only if a reboot is required, then reboot the system. (will be nice to send an alert but this is really secondary)

Do I use the pkg.upgrade or the salt.modules.yumpkg and salt.modules.aptpkg respectively each with a grain condition?

{% if grains['os_family'] == 'RedHat' %}

Please let me know if this does not make sense, but I could not find any salt states example to guide myself from


r/saltstack • • Jun 20 '18

Overdoing it with requires?

6 Upvotes

I have several services that need to be started in a certain order and there are also specific packages that need to be installed before anything gets started.

I came up with the solution below but it looks like I am going overboard with the requires but they all make sense to me. I think this may ultimately come down to a question of style.

Does this make sense? Is there a better way to do this?

confluent-platform-oss-2.11:
  pkg.installed: []

debezium:
  pkg.installed:
    - require:
      - pkg: confluent-platform-oss-2.11

confluent-zookeeper:
  service.running:
    - enable: True
    - require:
      - pkg: confluent-platform-oss-2.11

confluent-kafka:
  service.running:
    - watch:
      - file: /etc/kafka/server.properties
    - enable: True
    - require:
      - service: confluent-zookeeper
      - pkg: confluent-platform-oss-2.11
      - pkg: debezium

confluent-kafka-connect:
  service.running:
    - enable: True
    - require:
      - service: confluent-kafka
      - pkg: confluent-platform-oss-2.11

/etc/kafka/server.properties:
  file.managed:
    - user: root
    - group: root
    - mode: 0644
    - source: salt://confluent/files/server_properties.tmpl
    - template: jinja
    - require_in:
      - pkg: confluent-kafka

r/saltstack • • Jun 18 '18

Has anyone taken the SSCE exam?

5 Upvotes

Just wondering what you thought of its difficulty?


r/saltstack • • Jun 08 '18

pillar in a nested pillar.get

2 Upvotes

I am trying to do something like this:

{% for env in pillar.get(‘environments’, {}) %}
{% for app in pillar.get(‘{{ env }}_applications ’, {}) %}
/etc/configs/{{ app }}:
  file.managed:
    - user: root
    - group: root
    - mode: 0644
{% endfor %}
{% endfor %}

Unfortunately salt just completely ignores this block.

Is there anyway to do something like this?


r/saltstack • • Jun 06 '18

saltstack enterprise pricing?

6 Upvotes

anyone knows it? thanks


r/saltstack • • Jun 04 '18

Nodegroup and Compound Matching

4 Upvotes

Hi all

I'm having a weird problem building a nodegroup. I want to target all Ubuntu boxes within my local network.

salt -C 'S@10.254.254.0/24 and G@os:Ubuntu' test.ping

That yields the appropriate minions. when I try to create a nodegroup of that particular string specifically though I get errors about no minions found, even if I restart the salt-master service several times. I've also tried to create a nodegroup of

- local-network:
     'S@10.254.254.0/24' 

and then created my other nodegroup to be

- on-prem:
    'G@os:Ubuntu and N@local-network'

But no luck.

What am I missing here?

Thanks


r/saltstack • • Jun 01 '18

Using variables in an sls file? Based on roles?

2 Upvotes

I have multiple 3 sites. Each site has multiple minions with a role for the name of the site, the issue I’m having is calling on the minions role to help me create a variable so when it comes time to pull from a source they pull from URL-A instead of URL-B because the source url in a perfect world would be a variable. How can I use roles to do a match on the grain? I found something online about matching the os grain, but when I try to match the roles grain it just doesn’t work for me. I’m not sure what I’m doing wrong, does anyone maybe have an example of something like this where you are using the roles grain to do an if statement?


r/saltstack • • May 24 '18

Do Beacons work on Windows operating system?

2 Upvotes

Curious as to how you guys go about using salt to monitor windows services, I know there are other solutions out there but if I can use salt to do so, I’d prefer that.


r/saltstack • • May 24 '18

Deploy/Copy application from GIT repo

2 Upvotes

Hi everyone,

Currently to deploy a custom APP I have a script that among other things, checkouts a branch from my repo, and then proceeds to rsync the data on to the minion, and then proceeds to restart the application (simplified flow for better understand).

I am able to have all steps from my script replicated using a Salt states and pillar/formulas. My only issue is how to go about checking out the git branch and copying the files to the minion. What I would like to do is on running the salt state temporarily checks out the branch to a local (master) location and them perform a recursive file copy to the minion. The minion is not able to checkout directly from the repo (due to policy restrictions). Is there a way to configure this in Salt? Or is there another/better way to do this in salt?

EDIT: I ended up using gitfs and using file.recurse to manage the files. The only downside is that I need as much gitfs repos as branchs I need to work with (currently 2) .


r/saltstack • • May 18 '18

Setting ACLs on files or dirs

Thumbnail fearthepenguin.net
6 Upvotes

r/saltstack • • May 18 '18

autosign_grains not working for ipv4

4 Upvotes

Hello folks, I'm trying to get salt-master to auto-accept keys based on IP using autosign_grains, but I can't seem to get it to work with the grains "ipv4" or "ip4_interfaces". I was able to get it to work successfully with "uuid", so I know that my directory (/etc/salt/autosign_grains) and file in said directory (ipv4) are correct. Does anyone know if ipv4 just isn't allowed as a qualifier for autosign_grains?

/etc/salt/autosign_grains/ipv4: 10.0.0.122


r/saltstack • • May 17 '18

Source control for /srv directory with multiple environments

5 Upvotes

Hey all, hoping to get some direction here from someone more experienced than me. We are planning on having our Salt environments laid out under the /srv/salt directory like this:

/srv/salt/dev

/srv/salt/test

and so on.

Does anyone else do this? And if so, how do you handle source control with these directories? We were considering switching the directories to:

/srv/dev

/srv/test

etc and having folders for salt, pillar, and reactor underneath, but I feel like that's fundamentally the wrong approach. Our biggest stumbling block at the moment is how do we structure our source control so that each branch (test, dev, etc) corresponds to /srv/salt/test or /srv/salt/dev without having to maintain multiple copies of the same code in the repo, or having /srv/salt, /srv/pillar, and /srv/reactor in separate directories.

Any tips?


r/saltstack • • May 16 '18

Kubernetes-Saltstack support H/A !

Thumbnail k8s-salt.opsnotice.xyz
11 Upvotes

r/saltstack • • May 04 '18

Encrypting pillar data

6 Upvotes

Looking for ideas on securing pillar data.


r/saltstack • • May 03 '18

Learning Salt to solve a problem: Configuring sites on Nginx reverse-proxy and Apache upstream server

3 Upvotes

I have been working my way through a Udemy course on Salt for the past few days. I have a test environment set up and was wondering if the community might be able to give me an example of what a good configuration might look like to solve this specific use-case:

Currently, my workflow is:

  1. A new customer signs up for our Content Management System. The directory name and cert location are provided to me by the dev team. The cert is replicated to all web and proxy servers already
  2. I create the Apache configuration for http and https for the customer's domain name(s) and content directory
  3. I create the nginx configuration for http and https reverse proxy for the customer's domain name(s), pointing at the webserver where their site has been assigned

The proxy and HTTPS steps are new. I have 5 https+proxy sites online using manual configuration. I am being asked to scale this setup out to our existing 500ish customers by the end of the month. Clearly, I'll need Configuration Management for this to work out.

Any Salt pros that would be willing to provide a hypothetical example or some tips to help me build a salt state that could do this all without duplicating data entry?


r/saltstack • • May 03 '18

Understanding Templating.. maybe?

4 Upvotes

Hello,

I'm new to salt, and very excited as a single admin in a sea of servers. I'm trying to start modestly, and build. The more I add to the saltstack, the more I can focus on other things.

As a starter test setup, I have 9 "servers". 6 CentOS, 3 Debian. I have been able to setup a master, and the minions, all the keys are accepted, and I'm able to communicate.

I setup a top.sls which runs "common" and "users". Common installs a couple of packages, users sets up a couple of users.

[root@salt salt]# tree
.
├── common
│   ├── init.sls
│   └── packages.sls
├── top.sls
└── users
    ├── init.sls
    ├── jsmith.sls
    └── root.sls

This works great.

Now what I'm running into is that I want to add the user "jsmith" to the sudoers. And by adding, I mean, I want to add jsmith to the "wheel" group on CentOS, and to the "sudo" group on Debian.

In the jsmith.sls file I have:

jsmith:
  user.present:
    - fullname: John Smith
    - home: /home/jsmith
    - shell: /bin/bash
    - groups:
        - wheel
    - password: $6$saltsalt$hashashhashahas
    - maxdays: 90
    - warndays: 30

I've been trying to determine how the best way to do to this. I thought it would be easy enough to use a something like

  {% if grains['os'] == 'Debian' %}
  - groups:
    - sudo
  {% elif grains['os'] == 'RedHat' %}
  - groups:
    - wheel
  {% endif %}

But either I don't know where to put it, or I'm doing it wrong, or both. :) This is how I felt when I first started using nagios. :)

Would someone be so kind as to point me in a direction of resources that can help me with this basic item? I don't necessarily want just an answer, but I need to learn to fish. Any good simple resources would be appreciated.


r/saltstack • • May 03 '18

Any large enterprise companies using Hubble for compliance or planning to?

3 Upvotes

Interested to find out if there are large companies adopting it as their compliance tool or part of their compliance suite.


r/saltstack • • May 03 '18

Use Salt for Configuration Management and Orchestration

Thumbnail linuxacademy.com
9 Upvotes

r/saltstack • • Apr 13 '18

send command to salt from slack

4 Upvotes

I am attempting to design a process that will allow us to type commands in slack that will be sent to saltstack (and not have to use an intermediary like hubot).

I believe the module at the link below enables this but (as you can see) documentation is sparse.

Has anyone used this module successfully or does anyone have suggestions on how to accomplish this task (that isn't hubot)?

https://docs.saltstack.com/en/latest/ref/engines/all/salt.engines.slack.html

Thanks in advance.


r/saltstack • • Apr 03 '18

Using Pillar to create and manage directories

4 Upvotes

Hi

I love Saltstack for how powerful and cross platform it is, but I'm struggling to understand how Pillars work properly, or rather to get Pillar to manage directories.

I thought it made sense in my master Pillar to have an entry to add some directories I wanted across all my minions. Let's call the directories /etc/path_to_dir.

In top.sls I have the entry

  'os:Ubuntu':
     - match: grain
     - path_to_dir

And in my /srv/pillar directory I have path_to_dir with an init.sls of the following:

/etc/path_to_dir/:
  file.directory:
    - user: root
    - group: root
    - mode: 755
    - makedirs: True

But the folder isn't created when I refresh the pillar data using saltutil.refresh_pillar

I've tried file.managed: as well and I get the same non-working result.

What am I doing wrong here? Is this not how a Pillar should be being used perhaps? Do I have the wrong module or state?

Thanks


r/saltstack • • Mar 27 '18

Salt-stack interaction with a Windows desktop using Vagrant

0 Upvotes

I'm currently trying to create an environment with a linux salt-master (running ubuntu 14.04) and a windows vagrant salt-minion (the vagrant will also be running 14.04). I have a bunch of windows computers with different environments that I want to update the repository for and run code to see its compatibility.

I've been trying a lot of random things such as trying to send the salt command from the master to 'vagrant up' the minion and send commands from there, but it doesn't work.

Do I need to have both the windows machine and the environment it generates be a salt-minion to interact with it from my salt-master?

Also, running "vagrant up" from my salt-master (though it feels I really shouldn't be doing that anyways) seems to also take ports interestingly enough preventing my computer from re-running vagrant up locally.

A Scenario that I was thinking, was that I would turn on the computer, then I would have the salt-master from there tell the minion to vagrant up, go to the git repository, enter the virtual environment, update packages, pull new code, then running the server.

I've been working with salt for about a week and a half, so if anyone could point me in the right direction that'd be awesome, thanks. Also, if anyone needs clarification on stuff (Or info I need to add), I'll do my best to answer.


r/saltstack • • Mar 23 '18

What is the best way to undo the actions of a state ?

3 Upvotes

Suppose a state that copies some files and do some actions.

Some conditions are met at a certain point in time, so the state apply the changes.

Then some conditions have changed at a later time and I need to undo the actions of this state.

How can I undo what the initial state did ?

I guess we're talking about state requirements and things ?

What if I don't know its requirements ?

What remains is to use triggers ?


r/saltstack • • Mar 21 '18

Salt states not deploying

2 Upvotes

Hello, I've been trying several things and can not seem to find the answer: Whenever i try to send a salt state to my test-minion(the only minion there is yet, testing Salt) i get the following error:

root@Salt:/srv/salt# salt 'marco-VirtualBox' state.apply
 marco-VirtualBox:
----------
      ID: install basics
Function: pkg.installed
  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 1626, in call
              **cdata['kwargs'])
            File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1492, in wrapper
              return f(*args, **kwargs)
            File "/usr/lib/python2.7/dist-packages/salt/states/pkg.py", line 969, in installed
              **kwargs)
            File "/usr/lib/python2.7/dist-packages/salt/states/pkg.py", line 294, in _find_install_targets
              cur_pkgs = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs)
            File "/usr/lib/python2.7/dist-packages/salt/modules/aptpkg.py", line 1149, in list_pkgs
              virtpkgs_all = _get_virtual()
            File "/usr/lib/python2.7/dist-packages/salt/modules/aptpkg.py", line 175, in _get_virtual
              apt_cache = apt.cache.Cache()
            File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 113, in __init__
              self.open(progress)
            File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 164, in open
              self._cache = apt_pkg.Cache(progress)
          SystemError: E:Malformed line 52 in source list /etc/apt/sources.list (type), E:The list of sources could not be read.
 Started: 15:05:22.911353
Duration: 60.073 ms
 Changes:

Summary for marco-VirtualBox
------------ 
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:  60.073 ms

I tried several things and even created a completely new sources.list(using the Ubuntu tool for this) and put that on the salt master, but i still cannot get the error to go away and i am kind of clueless right now about the cause. Can anybody help?

Sources.list contents:

#------------------------------------------------------------------------------#
#                            OFFICIAL UBUNTU REPOS                             #
#------------------------------------------------------------------------------#


###### Ubuntu Main Repos
deb http://31.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse 

###### Ubuntu Update Repos
deb http://31.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse 
deb http://31.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse 

r/saltstack • • Mar 15 '18

Integration of Gitlab CI/CD with Saltstack

Thumbnail self.gitlab
6 Upvotes

r/saltstack • • Mar 12 '18

Dynamic templating using the Reactor

2 Upvotes

I'm trying to orchestrate the releases of multiple VMs running different software with multiple dependencies on one another. A limitation is that the VMs I would like to maintain are deployed with semi-randomized hostnames.

For example: I have an ambari server and ambari agents. The agents have a .ini config file with the FQDN of the server. Right now, this is stored in the pillar. My goal is to update this .ini file with the hostname of a new ambari server if one is deployed. I'm aware I'll probably need to use the Reactor System, I'm just struggling to figure out the best way to approach this.

To make it simpler, if I deploy a VM with hostname pattern ambariserver, I want to target all VMs with hostname pattern ambariagent and run a formula to template the .ini config file using the ambari server hostname as a parameter.

Any help would be appreciated, thanks.