Browse Source

Merge pull request #217 from prometheanfire/fix-module.run

allow use of new state syntax for module.run
pull/222/head
Filip Pytloun 4 years ago
parent
commit
d15dfbca09
No account linked to committer's email address
7 changed files with 64 additions and 2 deletions
  1. +7
    -0
      linux/network/host.sls
  2. +6
    -0
      linux/network/openvswitch.sls
  3. +29
    -2
      linux/storage/disk.sls
  4. +6
    -0
      linux/storage/swap.sls
  5. +6
    -0
      linux/system/cpu.sls
  6. +4
    -0
      linux/system/repo.sls
  7. +6
    -0
      linux/system/sysfs.sls

+ 7
- 0
linux/network/host.sls View File



linux_host_{{ name }}_order_fix: linux_host_{{ name }}_order_fix:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- file.replace:
- path: /etc/hosts
- pattern: {{ before }}
- repl: {{ after }}
{%- else %}
- name: file.replace - name: file.replace
- path: /etc/hosts - path: /etc/hosts
- pattern: {{ before }} - pattern: {{ before }}
- repl: {{ after }} - repl: {{ after }}
{%- endif %}
- watch: - watch:
- host: linux_host_{{ name }} - host: linux_host_{{ name }}
- onlyif: - onlyif:

+ 6
- 0
linux/network/openvswitch.sls View File

- template: jinja - template: jinja
- require: - require:
- pkg: openvswitch_pkgs - pkg: openvswitch_pkgs

openvswitch_sytemctl_reload:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- service.systemctl_reload: []
{%- else %}
- name: service.systemctl_reload - name: service.systemctl_reload
{%- endif %}
- onchanges: - onchanges:
- file: /etc/systemd/system/openvswitch-switch.service - file: /etc/systemd/system/openvswitch-switch.service



+ 29
- 2
linux/storage/disk.sls View File



create_disk_label_{{ disk_name }}: create_disk_label_{{ disk_name }}:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- partition.mklabel:
- device: {{ disk_name }}
- label_type: {{ disk.get('type', 'dos') }}
{%- else %}
- name: partition.mklabel - name: partition.mklabel
- device: {{ disk_name }} - device: {{ disk_name }}
- label_type: {{ disk.get('type', 'dos') }} - label_type: {{ disk.get('type', 'dos') }}
{%- endif %}
- unless: "fdisk -l {{ disk_name }} | grep -i 'Disklabel type: {{ disk.get('type', 'dos') }}'" - unless: "fdisk -l {{ disk_name }} | grep -i 'Disklabel type: {{ disk.get('type', 'dos') }}'"
- require: - require:
- pkg: parted - pkg: parted


create_partition_{{ disk_name }}_{{ loop.index }}: create_partition_{{ disk_name }}_{{ loop.index }}:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- partition.mkpart:
- device: {{ disk_name }}
- part_type: primary
{%- if partition.type is defined %}
- fs_type: {{ partition.type }}
{%- endif %}
- start: {{ end_size }}MB
- end: {{ end_size + partition.size }}MB
{%- else %}
- name: partition.mkpart - name: partition.mkpart
- device: {{ disk_name }} - device: {{ disk_name }}
- part_type: primary - part_type: primary
{%- if partition.type is defined %}
{%- if partition.type is defined %}
- fs_type: {{ partition.type }} - fs_type: {{ partition.type }}
{%- endif %}
{%- endif %}
- start: {{ end_size }}MB - start: {{ end_size }}MB
- end: {{ end_size + partition.size }}MB - end: {{ end_size + partition.size }}MB
{%- endif %}
- unless: "blkid {{ disk_name }}{{ loop.index }} {{ disk_name }}p{{ loop.index }}" - unless: "blkid {{ disk_name }}{{ loop.index }} {{ disk_name }}p{{ loop.index }}"
- require: - require:
- module: create_disk_label_{{ disk_name }} - module: create_disk_label_{{ disk_name }}


probe_partions_{{ disk_name }}: probe_partions_{{ disk_name }}:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- partition.probe:
- device: {{ disk_name }}
{%- else %}
- name: partition.probe - name: partition.probe
- device: {{ disk_name }} - device: {{ disk_name }}
{%- endif %}


{%- for partition in disk.get('partitions', []) %} {%- for partition in disk.get('partitions', []) %}




mkfs_partition_{{ disk_name }}_{{ loop.index }}: mkfs_partition_{{ disk_name }}_{{ loop.index }}:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- xfs.mkfs:
- device: {{ disk_name }}{{ loop.index }}
{%- else %}
- name: xfs.mkfs - name: xfs.mkfs
- device: {{ disk_name }}{{ loop.index }} - device: {{ disk_name }}{{ loop.index }}
{%- endif %}
- unless: "blkid {{ disk_name }}{{ loop.index }} {{ disk_name }}p{{ loop.index }} | grep xfs" - unless: "blkid {{ disk_name }}{{ loop.index }} {{ disk_name }}p{{ loop.index }} | grep xfs"
- require: - require:
- module: create_partition_{{ disk_name }}_{{ loop.index }} - module: create_partition_{{ disk_name }}_{{ loop.index }}

+ 6
- 0
linux/storage/swap.sls View File



{{ swap.device }}: {{ swap.device }}:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- mount.rm_fstab:
- m_name: none
- device: {{ swap.device }}
{%- else %}
- name: mount.rm_fstab - name: mount.rm_fstab
- m_name: none - m_name: none
- device: {{ swap.device }} - device: {{ swap.device }}
{%- endif %}
- onlyif: grep -q {{ swap.device }} /etc/fstab - onlyif: grep -q {{ swap.device }} /etc/fstab


linux_disable_swap_{{ swap.engine }}_{{ swap.device }}: linux_disable_swap_{{ swap.engine }}_{{ swap.device }}:

+ 6
- 0
linux/system/cpu.sls View File

{% if salt['file.file_exists']('/sys/'+ core_key) %} {% if salt['file.file_exists']('/sys/'+ core_key) %}
governor_write_sysfs_cpu_core_{{ cpu_core }}: governor_write_sysfs_cpu_core_{{ cpu_core }}:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- sysfs.write:
- key: {{ core_key }}
- value: {{ system.cpu.governor }}
{%- else %}
- name: sysfs.write - name: sysfs.write
- key: {{ core_key }} - key: {{ core_key }}
- value: {{ system.cpu.governor }} - value: {{ system.cpu.governor }}
{%- endif %}
{% endif %} {% endif %}


{%- endfor %} {%- endfor %}

+ 4
- 0
linux/system/repo.sls View File

refresh_db: refresh_db:
{%- if system.get('refresh_repos_meta', True) %} {%- if system.get('refresh_repos_meta', True) %}
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- pkg.refresh_db: []
{%- else %}
- name: pkg.refresh_db - name: pkg.refresh_db
{% endif %}
{%- else %} {%- else %}
test.succeed_without_changes test.succeed_without_changes
{%- endif %} {%- endif %}

+ 6
- 0
linux/system/sysfs.sls View File

{#- Sysfs cannot be set in docker, LXC, etc. #} {#- Sysfs cannot be set in docker, LXC, etc. #}
linux_sysfs_write_{{ list_idx }}_{{ name }}_{{ key }}: linux_sysfs_write_{{ list_idx }}_{{ name }}_{{ key }}:
module.run: module.run:
{%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
- sysfs.write:
- key: {{ key }}
- value: {{ value }}
{%- else %}
- name: sysfs.write - name: sysfs.write
- key: {{ key }} - key: {{ key }}
- value: {{ value }} - value: {{ value }}
{%- endif %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}

Loading…
Cancel
Save