manage with contents to simplify salt cloud profile file_map

This commit is contained in:
m0duspwnens
2025-01-29 08:12:50 -05:00
parent ea2e026c56
commit 3c85b48291
3 changed files with 25 additions and 18 deletions

View File

@@ -35,9 +35,15 @@ sool9-{{host}}:
# - echo "preflight_cmds"
# the destination directory will be created if it doesn't exist
file_map:
/opt/so/saltstack/default/salt/setup/virt/initial_schedule.sls: /opt/so/conf/salt/cloud_file_map/salt/initial_schedule.sls
/opt/so/saltstack/default/salt/setup/virt/initial_schedule.sls: /opt/so/conf/salt/cloud_file_map/salt/setup/virt/initial_schedule.sls
/opt/so/saltstack/default/salt/salt/mine_functions.sls: /opt/so/conf/salt/cloud_file_map/salt/salt/mine_functions.sls
inline_script:
- "sudo salt-call state.apply initial_schedule --local --file-root=/opt/so/conf/salt/cloud_file_map/salt/"
- |
sudo salt-call state.apply salt.mine_functions \
--local \
--file-root=/opt/so/conf/salt/cloud_file_map/salt/ \
pillar='{"host": {"mainint": "eth0"}}'
- "sudo salt-call state.apply setup.virt.initial_schedule --local --file-root=/opt/so/conf/salt/cloud_file_map/salt/"
# - "rpm --import /tmp/securityonion.pub"
# grains to add to the minion

View File

@@ -1,14 +0,0 @@
{% if grains.role == 'so-hypervisor' %}
{% set interface = 'br0' %}
{% else %}
{% set interface = pillar.host.mainint %}
{% endif %}
mine_interval: 25
mine_functions:
network.ip_addrs:
- interface: {{ interface }}
{%- if grains.role in ['so-eval','so-import','so-manager','so-managersearch','so-standalone'] %}
x509.get_pem_entries:
- glob_path: '/etc/pki/ca.crt'
{% endif -%}

View File

@@ -6,8 +6,23 @@
# this state was seperated from salt.minion state since it is called during setup
# GLOBALS are imported in the salt.minion state and that is not available at that point in setup
# this state is included in the salt.minion state
{% set role = salt['grains.get']('role', '') %}
{% if role == 'so-hypervisor' -%}
{% set interface = 'br0' %}
{% else %}
{% set interface = pillar.host.mainint %}
{% endif %}
mine_functions:
file.managed:
- name: /etc/salt/minion.d/mine_functions.conf
- source: salt://salt/etc/minion.d/mine_functions.conf.jinja
- template: jinja
- contents: |
mine_interval: 25
mine_functions:
network.ip_addrs:
- interface: {{ interface }}
{%- if role in ['so-eval','so-import','so-manager','so-managersearch','so-standalone'] %}
x509.get_pem_entries:
- glob_path: '/etc/pki/ca.crt'
{% endif -%}