salt-stack

jinja2 get list of attributes

此生再无相见时 提交于 2019-12-12 01:26:12
问题 I'm using salt + jinja2 to template a context.xml file. I have the following pillar: context: db_server: some_server resources: some_customer: name: some_name user: some_user passwd: some_passwd this_customer: name: this_name user: this_user passwd: this_passwd I need to create a string with a list of the names for each customer. Right now I have this: {%- set nameList = pillar['context']['resources']|list()|join(', ') %} This gives me this list: 'some_customer, this_customer' . I'd like this

salt mine for all network interfaces

北城以北 提交于 2019-12-12 01:22:43
问题 I'm having difficulty configuring collectd.conf using the interface plugin through salt . The collectd.conf expects a list of network interfaces to monitor like: <Plugin interface> Interface "em1" Interface "em2" </Plugin> I've worked out that I need to use a salt mine to pull the grains into the master - which is achieved through a pillar sls like the following: mine_functions: network.interfaces: [] and in my collectd.conf I have: <Plugin interface> {% for host, info in salt['mine.get']('*'

Run downloaded SaltStack formula

二次信任 提交于 2019-12-11 17:49:58
问题 I've downloaded the PHP formula by following the instructions here: https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html I've changed apache to php . In my salt config file (which I assume is /etc/salt/master ), I've set file_roots like so: file_roots: base: - /srv/salt - /srv/formulas/php-formula I don't know how I'm supposed to run it now. I've successfully run a salt state file by discovering that the documentation is incomplete, so I'd missed a step I wasn't

including grain data when querying pillar in saltstack managed file

我与影子孤独终老i 提交于 2019-12-11 16:50:04
问题 I have a state using file.managed , which generates a config file via a jinja for loop from a key in pillar. My pillar looks like this: configuration: server01: key1: value1 key2: value2 server02: key03: value03 key04: value04 and the managed file: {% set kv = pillar['configuration']['server01'] %} {% for key, value in kv.iteritems() %} {{ key }}:{ value }}; {% endfor %} The way I differentiate between different servers right now in my state file is config: file.managed: - name: /etc/config

SSL Error on 8 on SaltStack using Tornado

99封情书 提交于 2019-12-11 14:12:26
问题 If I run: curl -si localhost:8000/login -H "Accept: application/json" -d username='salt' -d password='salt' -d eauth='pam' It gives this error: Process Manager starting! Enter PEM pass phrase: [WARNING ] SSL Error on 8 ('127.0.0.1', 50408): [Errno 1] _ssl.c:510: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request [ERROR ] Uncaught exception Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/tornado/http1connection.py", line 693, in _server_request_loop ret =

Should I edit the salt tar files after a Kubernetes cluster is running on Google Compute Engine?

可紊 提交于 2019-12-11 04:54:21
问题 I've used curl -sS https://get.k8s.io | bash to create a cluster on Google Compute Engine using Kubernetes 1.2.4. This worked great. I wanted to enable ABAC authorization mode by adding a few flags to the kube-apiserver command specified in kube-apiserver pod spec. I'm unclear if I should adjust the salt files once they're tar/gzipped. The salt file that the pod spec is generated from is here, but editing this after the cluster is stood up has a few additional requirements: I have to unpack

Using formulas with saltstack

我与影子孤独终老i 提交于 2019-12-11 03:44:21
问题 I'm new on saltstack and I want to install postgres or apache or anyting else by using saltstack formulas. I downloaded repo from git with git clone https://github.com/saltstack-formulas/apache-formula.git and git clone https://github.com/saltstack-formulas/postgres.git to my /srv/salt directory. After that I added the lines file_roots: base: - /srv/salt - /srv/formulas/apache-formula - /srv/formulas/postgres in /etc/salt/master file. Then i created a file top.sls in the folder /srv/salt with

SaltStack: Do … if group “foo” exists on remote-host

百般思念 提交于 2019-12-10 21:14:45
问题 How can I implement a condition bases on the fact that the remote-host a group called "foo" or not. My use case: If there is a group called "foo" on the remote-host, then I need to add a user to it. If the group does not exist, then nothing needs to be done. Is this possible with SaltStack? 回答1: You need Jinja renderers in your salt states file and mix with salt.states.user.present. (Update) . you can use an salt override modules pw_group {% if salt['group.info']("foo") %} add new user if foo

YAML syntax for Salt and Python

点点圈 提交于 2019-12-10 19:49:23
问题 What is the diference between this: dic1: - subdict1.1: value11.1 - subdict1.2: value1.2 - cubdict1.3: value1.3 and This: dict2: subdict2.1: value2.2 subdict2.1: value2.2 subdict2.3: value2.3 I know the first one evaluates to a list of dictionaries. but what is the second one? isn't also a list of dictionaries? 回答1: No, it is just a nested dictionary. Example YAML code: first_level_dict_key: second_level_dict_key: value_in_second_level_dict Results in Python : { 'first_level_dict_key': {

Is there any difference between “json” and “tojson” filters in jinja for saltstack?

天涯浪子 提交于 2019-12-10 19:21:44
问题 According to saltstack documentation it's "json": https://docs.saltstack.com/en/latest/ref/renderers/all/salt.renderers.jinja.html But in jinja doc http://jinja.pocoo.org/docs/2.9/templates/#builtin-filters - there is not "json", but "tojson". Does anybody know why? 回答1: While I can't say absolutely for sure, I have an impression that Salt Renderers are built-in for Salt only. For example, there are also yaml and python renderers, but there is no corresponding filter for Jinja. So, json