README.md 1.5 KB
Newer Older
remy's avatar
remy committed
1
# Set Grains
remy's avatar
remy committed
2

remy's avatar
remy committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
This SaltStack formula defines additional grains to apply on the host based on its subnets and its Salt ID (`minion id` or `hostname` otherwise).

Caution: 
> Version 3001 has a bug with an impossible deletion when the grain value is a list : https://github.com/saltstack/salt/issues/57718
> The value must then be re-assigned to this grain by forcing it `salt '$minion' grains.set pool foo force=True`), then delete it again with `salt '$minion' grains.delkey pool`.

Usage:
```bash
salt '*' state.sls set_grains
```

```bash
# to delete a grain value in a list
salt 'target' grains.remove roles <value>
# to delete a whole key, use:
salt 'target' grains.delval key
```

Edit `poolroles.sls` and `pillar.roles.example` to fit your needs.

## Parent

remy's avatar
remy committed
25
`Parent` is used and may be uncomment in `init.sls` to specify a `parent` grain. It allows us to create a diagram with machine hardware dependencies.
remy's avatar
remy committed
26

remy's avatar
remy committed
27
For example, you can imagine having a _proxmox_ server with some virtual machines or containers.
remy's avatar
remy committed
28

remy's avatar
remy committed
29
  - The _proxmox_ server will have a pillar value of machine type: `machine_type: host`,
remy's avatar
remy committed
30
31
32
33
34
35
36
37
38
  - A virtual machine will have a pillar value of machine type: `machine_type: vm`,
  - A container will have a pillar value of machine type: `machine_type: container`.

Those 3 type of machines will also have an IP address.

VM and containers will also have a `url_mgmt` pillar value.
This value is used to check if a IP address is already present in host machines.

See `hosts212.example` for more informations on how to do this.