KP
Size: a a a
KP
L
{%- set mountpoints = salt['pillar.get']('mountpoints') %}
{%- for mountpoint in mountpoints %}
{%- if not salt['mount.is_mounted'](mountpoint) %}
{%- set disk_number = 1 + loop['index'] %}
{%- for block_device in salt['partition.get_block_device']() %}
{%- set block_device_size = salt['partition.list'](device='/dev/' ~ block_device, unit='GiB')['info']['size'].split('.')[0] %}
{%- set block_device_vm_disk_number = block_device_size | list | last %}
{%- if block_device_vm_disk_number | int == disk_number | int %}
{%- if not salt['partition.exists']('/dev/' ~ block_device ~ '1') %}
{{ sls }} - create gpt table and partition on {{ '/dev/' ~ block_device ~ '1' }}:
cmd.run:
- creates: {{ '/dev/' ~ block_device ~ '1' }}
- name: bash -c 'parted --script {{ '/dev/' ~ block_device }} mktable gpt \ mkpart gpt ext4 0% 100%'
{%- else %}
{{ sls }} - format partition - {{ '/dev/' ~ block_device ~ '1' }}:
blockdev.formatted:
- name: {{ '/dev/' ~ block_device ~ '1' }}
- fs_type: ext4
{%- if salt['disk.blkid']('/dev/' ~ block_device ~ '1')['/dev/' ~ block_device ~ '1']['UUID'] is defined %}
{%- set fs_uuid = salt['disk.blkid'](device='/dev/' ~ block_device ~ '1')['/dev/' ~ block_device ~ '1']['UUID'] %}
{{ sls }} - {{ mountpoint }}:
mount.mounted:
- name: {{ mountpoint }}
- device: UUID={{ fs_uuid }}
- fstype: ext4
- opts: defaults
- dump: 0
- pass_num: 2
- persist: True
- mkmnt: True
{%- endif %}
{%- endif %}
{%- break %}
{%- else %}
{%- continue %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}KP
KP
- device:
UUID=__slot__:salt:disk.blkid(device='/dev/' ~ block_device ~ '1')['/dev/' ~ block_device ~ '1']['UUID']
KP
KP
KP
J
unless если передать в него две проверки?default-python3-pkg:
pkg.installed:
- pkgs:
- python3
- unless:
- pkg.is_installed:
name: rh-python36-python
- pkg.is_installed:
name: rh-python35-pythonunless будут через AND или через OR собираться?R
vim:In the example above, the state will only run if either the vim-enhanced package is not installed (returns False) or if /usr/bin/vim does not exist (returns False). The state will run if both commands return False.
pkg.installed:
- unless:
- rpm -q vim-enhanced
- ls /usr/bin/vim
R
- unless:
- pkg.is_installed:
name: rh-python36-python
а это прям работает? ...
- unless:
- fun: pkg.version
args:
- mysql-server-5.7
Changed in version 3000: The unless requisite can take a module as a dictionary field in unless. The dictionary must contain an argument fun which is the module that is being run, and everything else must be passed in under the args key or will be passed as individual kwargs to the module function.