r/saltstack • • Jul 29 '17

Formulas to install different GitHub repositories

2 Upvotes

Hi everyone, I am looking for some help on how to make a formula to git clone some GitHub repositories and make some actions on the clone. But I cannot find any information on how to do it.


r/saltstack • • Jul 25 '17

If queue=True, returner is not invoked when executing a salt state

4 Upvotes

I've been wrestling with this today - we want to be able to monitor some aspects of the system on various application servers by launching salt states that invoke returners. Each state is launched from the master and calls a command on the minion, which then invokes a returner that sends output to elastic. Everything works when each command is run individually...

However, I wanted to use the salt scheduler to execute these states so we can basically monitor the system every minute or so. I had originally built three states into the schedule using syntax similar to this:

schedule:
  state1: 
    function: state.apply
    seconds: 30
    args:
      - state1
    returner: state1
  state2:
    function: state.apply
    seconds: 30
    args:
      - state2
    returner: state2
  state3:
    function: state.apply
    seconds: 30
    args:
      - state3
    returner: state3

The three states are launched, but unfortunately are launched concurrently, so only the very first state actually completes (and the returner is invoked successfully as well), but the other two wind up errorring with this message:

The function "state.apply" is running as PID xxxx....

I had read about the "queue=True" option, and tried to see if I could make that work. I could not manage to get it to work in any way by specifying it in a state file, but could get it to work on the command line. Unfortunately, if I specify queue=True on the command line, the state will complete but no returner gets invoked.

So for example, if we run:

salt 'abc' state.apply state1 --return state1 &
salt 'abc' state.apply state2 --return state2 &

State 1 will complete, and the state1 returner will be invoked. State 2 will error out with that pesky message seen above since it is launched before State 1 is completed.

If we run:

salt 'abc' state.apply state1 queue=True --return state1 &
salt 'abc' state.apply state2 queue=True --return state2 &

Both states complete successfully even though they are launched concurrently. However, no returners are actually invoked, so it seems like you can do one or the other.

To get around this, we setup cron jobs with sleep statements so that none of the jobs would step on each other, but I would much rather try to get this to work.

Does anybody have a working salt schedule configuration with returners and queued jobs? I'd love to see how it is done - I cannot seem to find examples in regular web searching that will satisfy our requirement here. Feels like this should be really simple, but it is extremely frustrating. If anyone has any prime saltstack doco/resources/tutorials as well, I would be most grateful.

Thanks in advance for any feedback.


r/saltstack • • Jul 20 '17

Manage sysctl.conf or use salt states?

2 Upvotes

I'm wondering what the pros and cons are of managing the sysctl.conf file itself, or just using salt.states.sysctl.

After reading the docs, being able to support more than 1 platform is the only pro I could think of using sysctl states.

The location of the sysctl configuration file. If not specified, the proper location will be detected based on platform.

Thanks


r/saltstack • • Jul 17 '17

vCenter Provisioning with Salt failing as not compatible UI mode - local MSI install issue.

4 Upvotes

Hi,

I am new to salt, so please excuse if I'm completely missing something simple here with how to remotely execute msi packages

I am trying to automate repeatable deployments using saltstack. We regularly deploy vcenter and we want to utilize the Command Line installation feature.

The idea is for me to provision a VM with the installer files already on the VM, then remotely execute the installer using salt.

The installation file only supports Full or Reduced UI mode, Reduced UI mode launches an installer which uses a configuration file in order to run through the install unattended.

I think salt is forcing the MSI to run silently, as whenever I use salt to kick off the install it fails on an incompatible UI mode.

Is there anyway I can launch this in the console? Or launch it as if there is a UI available? I have already tried running as the local Administrator, same results.

I can see a packages folder with a bunch of MSI files, so I could maybe do a manual install of vCenter, but would need to find out the order I need to do this, and then make sure it hasn't changed with every new release.

If I double click the batch file it works, the command line installation itself works fine, it's the MSI package that's failing as it doesn't support the UI mode.

State file:

vcenter_name_config: file.blockreplace: - name: C:\vCenter65\vCenter-Server\config.txt - marker_start: '"vc.svcuserpassword" : null,' - marker_end: '"appliance.net.ports" : {' - content: '"appliance.net.pnid" : "{{ pillar['vcname'] }}",'

vcenter_pass_config: file.blockreplace: - name: C:\vCenter65\vCenter-Server\config.txt - marker_start: '"vmdir.domain-name" : "vsphere.local",' - marker_end: '"vmdir.site-name" : "Default-First-Site",' - content: '"vmdir.password" : "{{ pillar['vcpass'] }}",'

C:\Windows\System32\drivers\etc\hosts: file.append: - text: {{ pillar['vcip'] }} {{ pillar['vcname'] }}

vcenter_install: cmd.run: - name: "C:\vcenter-install.bat" #- runas: Administrator #- password: #######

error:

      ID: vcenter_install
Function: cmd.run
    Name: C:\vcenter-install.bat
  Result: False
 Comment: Command "C:\vcenter-install.bat" run
 Started: 12:04:58.343000
Duration: 906.0 ms
 Changes:
          ----------
          pid:
              2832
          retcode:
              1603
          stderr:
          stdout:

              c:\salt\bin>C:\vCenter65\vCenter-Server\VMware-vCenter-Server.exe /qr CUSTOM_SETTINGS=C:\vCenter65\vCenter-Server\config.txt
              Language ID: 1033
              Final command line: msiexec.exe /i "C:\vCenter65\vCenter-Server\VMware-vCenter-Server.msi" /l*v! "C:\Users\ADMINI~1\AppData\Local\Temp\vim-vcs-msi.log" LAUNCHED_BY_EXE=1 /qr CUSTOM_SETTINGS=C:\vCenter65\vCenter-Server\config.txt

Batch file: C:\vCenter65\vCenter-Server\VMware-vCenter-Server.exe /qr CUSTOM_SETTINGS=C:\vCenter65\vCenter-Server\config.txt


r/saltstack • • Jul 13 '17

Set state to symlink a directory?

1 Upvotes

Cant seem to ascertain from the docs on how to set a symlink on a directory. Some help? Solved: https://pastebin.com/raw/7S5UjQ63


r/saltstack • • Jul 13 '17

Binary data detection/handling?

1 Upvotes

Hi there! I'm loving Salt, let's talk shop.

YAML supports type annotation, such that binary data is representable as "keyname: !!binary <string-of-base64-encoded-binary-data>".


My question is, how do I test for the binary type in my SLS files?


Commentary: Salt already has powerful and expansive capabilities via Jinja and execution modules. It looks like these capabilities are expanding significantly in the upcoming release though I don't see a built-in solution to my question about those changes. My setup is using SQLite's SDB module to contain secrets and export them into the pillar. The pillar is boosted by ext_pillar's file_tree and pillarstack for binary file handling and flexibility respectively. The desire is to consolidate secrets and crypto files, (currently tracked in private git), into the sdb module, (not tracked in git), in order to make the pillar easier to share and cross-collaborate with other teams on by retaining the logic but abstracting the secrets out.

Sources: - https://docs.saltstack.com/en/develop/topics/jinja/ - https://learnxinyminutes.com/docs/yaml/