浏览代码

allow use of new state syntax for module.run

The new syntax has been supported since ~2017.
From the docs, in case they change:

! New Style
test.random_hash:
  module.run:
    - test.random_hash:
      - size: 42
      - hash_type: sha256

! Legacy Style
test.random_hash:
  module.run:
    - size: 42
    - hash_type: sha256
pull/218/head
Matthew Thode 4 年前
父节点
当前提交
7cec39ddfa
共有 7 个文件被更改,包括 64 次插入2 次删除
  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 查看文件

@@ -70,10 +70,17 @@ linux_host_{{ name }}:

linux_host_{{ name }}_order_fix:
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
- path: /etc/hosts
- pattern: {{ before }}
- repl: {{ after }}
{%- endif %}
- watch:
- host: linux_host_{{ name }}
- onlyif:

+ 6
- 0
linux/network/openvswitch.sls 查看文件

@@ -19,8 +19,14 @@ openvswitch_pkgs:
- template: jinja
- require:
- pkg: openvswitch_pkgs

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


+ 29
- 2
linux/storage/disk.sls 查看文件

@@ -12,9 +12,15 @@ xfsprogs:

create_disk_label_{{ disk_name }}:
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
- device: {{ disk_name }}
- label_type: {{ disk.get('type', 'dos') }}
{%- endif %}
- unless: "fdisk -l {{ disk_name }} | grep -i 'Disklabel type: {{ disk.get('type', 'dos') }}'"
- require:
- pkg: parted
@@ -28,14 +34,25 @@ create_disk_label_{{ disk_name }}:

create_partition_{{ disk_name }}_{{ loop.index }}:
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
- device: {{ disk_name }}
- part_type: primary
{%- if partition.type is defined %}
{%- if partition.type is defined %}
- fs_type: {{ partition.type }}
{%- endif %}
{%- endif %}
- start: {{ end_size }}MB
- end: {{ end_size + partition.size }}MB
{%- endif %}
- unless: "blkid {{ disk_name }}{{ loop.index }} {{ disk_name }}p{{ loop.index }}"
- require:
- module: create_disk_label_{{ disk_name }}
@@ -47,8 +64,13 @@ create_partition_{{ disk_name }}_{{ loop.index }}:

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

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

@@ -56,8 +78,13 @@ probe_partions_{{ disk_name }}:

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

+ 6
- 0
linux/storage/swap.sls 查看文件

@@ -59,9 +59,15 @@ linux_set_swap_file_status_{{ swap.device }}:

{{ swap.device }}:
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
- m_name: none
- device: {{ swap.device }}
{%- endif %}
- onlyif: grep -q {{ swap.device }} /etc/fstab

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

+ 6
- 0
linux/system/cpu.sls 查看文件

@@ -30,9 +30,15 @@ ondemand_service_disable:
{% if salt['file.file_exists']('/sys/'+ core_key) %}
governor_write_sysfs_cpu_core_{{ cpu_core }}:
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
- key: {{ core_key }}
- value: {{ system.cpu.governor }}
{%- endif %}
{% endif %}

{%- endfor %}

+ 4
- 0
linux/system/repo.sls 查看文件

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

+ 6
- 0
linux/system/sysfs.sls 查看文件

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

正在加载...
取消
保存