Use items() instead of iteritems() for Python3 compatibility.pull/145/head
// apt.conf file managed by salt-minion | // apt.conf file managed by salt-minion | ||||
// DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | // DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | ||||
{%- for key, value in config.iteritems() %} | |||||
{%- for key, value in config.items() %} | |||||
{{ key }} {% if value is iterable and value is not string %}{ {% for entry in value %}"{{ entry }}";{% endfor %} } {% else %}{{ value }};{% endif %} | {{ key }} {% if value is iterable and value is not string %}{ {% for entry in value %}"{{ entry }}";{% endfor %} } {% else %}{{ value }};{% endif %} | ||||
{%- endfor %} | {%- endfor %} | ||||
{#- | {#- |
## | ## | ||||
## This is cgconfig configuration file is managed by Salt | ## This is cgconfig configuration file is managed by Salt | ||||
## | ## | ||||
{%- for cgroup_name, cg in system.cgroup.group.iteritems() %} | |||||
{%- for cgroup_name, cg in system.cgroup.group.items() %} | |||||
group {{ cgroup_name }} { | group {{ cgroup_name }} { | ||||
{%- for controller_name, controller in cg.controller.iteritems() %} | |||||
{%- for controller_name, controller in cg.controller.items() %} | |||||
{{ controller_name }} { | {{ controller_name }} { | ||||
{%- for v_name, v in controller.iteritems() %} | |||||
{%- for v_name, v in controller.items() %} | |||||
{{ controller_name }}.{{ v_name }}="{{ v.value }}"; | {{ controller_name }}.{{ v_name }}="{{ v.value }}"; | ||||
{%- endfor %} | {%- endfor %} | ||||
## This is cgrules configuration file is managed by Salt | ## This is cgrules configuration file is managed by Salt | ||||
## | ## | ||||
#<user/group> <controller(s)> <cgroup> | #<user/group> <controller(s)> <cgroup> | ||||
{%- for cgroup_name, cg in system.cgroup.group.iteritems() %} | |||||
{%- for cgroup_name, cg in system.cgroup.group.items() %} | |||||
{%- for subject in cg.mapping.subjects %} | {%- for subject in cg.mapping.subjects %} | ||||
{{ subject }}{% raw %} {% endraw %}{%- for controller_name, controller in cg.controller.iteritems() -%}{{ controller_name }}{%- if not loop.last -%},{%- endif -%}{%- endfor -%}{% raw %} {% endraw %}{{ cgroup_name }} | |||||
{{ subject }}{% raw %} {% endraw %}{%- for controller_name, controller in cg.controller.items() -%}{{ controller_name }}{%- if not loop.last -%},{%- endif -%}{%- endfor -%}{% raw %} {% endraw %}{{ cgroup_name }} | |||||
{%- endfor %} | {%- endfor %} | ||||
{%- endfor %} | {%- endfor %} |
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; | option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; | ||||
{{ render_section(dhclient) }} | {{ render_section(dhclient) }} | ||||
{%- if dhclient.get("interface") -%} | {%- if dhclient.get("interface") -%} | ||||
{%- for iface_name, options in dhclient.interface.iteritems() %} | |||||
{%- for iface_name, options in dhclient.interface.items() %} | |||||
{%- if network.interface.get(iface_name) and network.interface.get(iface_name).enabled == True | {%- if network.interface.get(iface_name) and network.interface.get(iface_name).enabled == True | ||||
and network.interface.get(iface_name).proto == 'dhcp' -%} | and network.interface.get(iface_name).proto == 'dhcp' -%} | ||||
interface "{{ iface_name }}" { | interface "{{ iface_name }}" { |
{%- from "linux/map.jinja" import network with context %} | {%- from "linux/map.jinja" import network with context %} | ||||
{%- for interface_name, interface in network.interface.iteritems() %} | |||||
{%- for interface_name, interface in network.interface.items() %} | |||||
{%- if 'dpdk' in interface.type and interface.pci is defined %} | {%- if 'dpdk' in interface.type and interface.pci is defined %} | ||||
pci {{ interface.pci }} {{ interface.driver }} | pci {{ interface.pci }} {{ interface.driver }} | ||||
{%- endif %} | {%- endif %} |
{%- for name,value in variables.iteritems() if not name.lower().endswith('_proxy') %} | |||||
{%- for name,value in variables.items() if not name.lower().endswith('_proxy') %} | |||||
{%- if value is sequence and value is not string %} | {%- if value is sequence and value is not string %} | ||||
{{ name }}="{{ value|join(':') }}" | {{ name }}="{{ value|join(':') }}" |
{%- from "linux/map.jinja" import system with context %} | {%- from "linux/map.jinja" import system with context %} | ||||
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT {%- for hugepages_type, hugepages in system.kernel.hugepages.iteritems() %}{%- if hugepages.get('default', False) %} default_hugepagesz={{ hugepages.size }} {%- endif %} hugepagesz={{ hugepages.size }} hugepages={{ hugepages.count }} {%- endfor %}" | |||||
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT {%- for hugepages_type, hugepages in system.kernel.hugepages.items() %}{%- if hugepages.get('default', False) %} default_hugepagesz={{ hugepages.size }} {%- endif %} hugepagesz={{ hugepages.size }} hugepages={{ hugepages.count }} {%- endfor %}" |
'ip6-allhosts' | 'ip6-allhosts' | ||||
], | ], | ||||
} -%} | } -%} | ||||
{%- for name, host in host_dict.iteritems() -%} | |||||
{%- for name, host in host_dict.items() -%} | |||||
{%- for hname in host.names -%} | {%- for hname in host.names -%} | ||||
{%- if hname in hosts.get('127.0.1.1', []) -%} | {%- if hname in hosts.get('127.0.1.1', []) -%} | ||||
{%- do hosts.pop('127.0.1.1') -%} | {%- do hosts.pop('127.0.1.1') -%} |
# Example | # Example | ||||
# Accept every block device: | # Accept every block device: | ||||
filter = [ {%- for vgname, vg in storage.lvm.iteritems() %}{%- if vg.get('enabled', True) %}{%- for dev in vg.devices %}"a|{{ dev }}*|"{%- if not loop.last %},{%- endif %}{%- endfor %}{%- endif %}{%- endfor %}, "r|.*|" ] | |||||
filter = [ {%- for vgname, vg in storage.lvm.items() %}{%- if vg.get('enabled', True) %}{%- for dev in vg.devices %}"a|{{ dev }}*|"{%- if not loop.last %},{%- endif %}{%- endfor %}{%- endif %}{%- endfor %}, "r|.*|" ] | |||||
# filter = [ "a|.*/|" ] | # filter = [ "a|.*/|" ] | ||||
# Reject the cdrom drive: | # Reject the cdrom drive: |
{%- from "linux/map.jinja" import system with context -%} | {%- from "linux/map.jinja" import system with context -%} | ||||
{%- for motd in system.motd -%} | {%- for motd in system.motd -%} | ||||
{%- if loop.index == index -%} | {%- if loop.index == index -%} | ||||
{%- for name, value in motd.iteritems() -%} | |||||
{%- for name, value in motd.items() -%} | |||||
{%- if name == motd_name -%}{{ value }}{%- endif %} | {%- if name == motd_name -%}{{ value }}{%- endif %} | ||||
{%- endfor -%} | {%- endfor -%} | ||||
{%- endif -%} | {%- endif -%} |
# unicast, could be multiline | # unicast, could be multiline | ||||
#netconsole ens3 192.168.1.32 fa:16:3e:8d:f6:d0 | #netconsole ens3 192.168.1.32 fa:16:3e:8d:f6:d0 | ||||
{%- if system.netconsole is mapping and system.netconsole.target is mapping %} | {%- if system.netconsole is mapping and system.netconsole.target is mapping %} | ||||
{%- for target, data in system.netconsole.target.iteritems() %} | |||||
{%- for target, data in system.netconsole.target.items() %} | |||||
{%- if data is mapping %} | {%- if data is mapping %} | ||||
netconsole "{{ data.get('interface', '${interface}') }}" "{{ target }}" "{{ data.get('mac', '') }}" | netconsole "{{ data.get('interface', '${interface}') }}" "{{ target }}" "{{ data.get('mac', '') }}" | ||||
{%- endif %} | {%- endif %} |
{%- if ldap.filter is defined %} | {%- if ldap.filter is defined %} | ||||
# Filters | # Filters | ||||
{%- for key, value in ldap.filter.iteritems() %} | |||||
{%- for key, value in ldap.filter.items() %} | |||||
filter {{ key }} {{ value }} | filter {{ key }} {{ value }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- endif %} | {%- endif %} | ||||
{%- if ldap.map is defined %} | {%- if ldap.map is defined %} | ||||
# Mappings | # Mappings | ||||
{%- for map_name,map in ldap.map.iteritems() %} | |||||
{%- for key, value in map.iteritems() %} | |||||
{%- for map_name,map in ldap.map.items() %} | |||||
{%- for key, value in map.items() %} | |||||
map {{ map_name }} {{ key }} {{ value }} | map {{ map_name }} {{ key }} {{ value }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- endfor %} | {%- endfor %} |
# Don't set prompt on non-interactive shell | # Don't set prompt on non-interactive shell | ||||
[[ $- == *i* ]] || return 0 | [[ $- == *i* ]] || return 0 | ||||
{%- for user, prompt in system.prompt.iteritems() %} | |||||
{%- for user, prompt in system.prompt.items() %} | |||||
{% if user != "default" %} | {% if user != "default" %} | ||||
if [ "$USERNAME" == "{{ user }}" ]; then | if [ "$USERNAME" == "{{ user }}" ]; then | ||||
export PS1="{{ prompt }} " | export PS1="{{ prompt }} " |
{%- for name, repo in default_repos.iteritems() %} | |||||
{%- for name, repo in default_repos.items() %} | |||||
# Repository {{ name }} | # Repository {{ name }} | ||||
{{ repo.source }} | {{ repo.source }} | ||||
{%- endfor %} | {%- endfor %} |
# sudoer aliases, file managed by salt-minion | # sudoer aliases, file managed by salt-minion | ||||
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | ||||
{%- for alias,commands in aliases.get('command',{}).iteritems() %} | |||||
{%- for alias,commands in aliases.get('command',{}).items() %} | |||||
Cmnd_Alias {{ alias }}={{ commands|join(', ') }} | Cmnd_Alias {{ alias }}={{ commands|join(', ') }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- for alias,users in aliases.get('user',{}).iteritems() %} | |||||
{%- for alias,users in aliases.get('user',{}).items() %} | |||||
User_Alias {{ alias }}={{ users|join(', ') }} | User_Alias {{ alias }}={{ users|join(', ') }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- for alias,users in aliases.get('runas',{}).iteritems() %} | |||||
{%- for alias,users in aliases.get('runas',{}).items() %} | |||||
Runas_Alias {{ alias }}={{ users|join(', ') }} | Runas_Alias {{ alias }}={{ users|join(', ') }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- for alias,hosts in aliases.get('host',{}).iteritems() %} | |||||
{%- for alias,hosts in aliases.get('host',{}).items() %} | |||||
Host_Alias {{ alias }}={{ hosts|join(', ') }} | Host_Alias {{ alias }}={{ hosts|join(', ') }} | ||||
{%- endfor %} | {%- endfor %} | ||||
# sudoer groups, file managed by salt-minion | # sudoer groups, file managed by salt-minion | ||||
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | ||||
{%- for group,spec in groups.iteritems() %} | |||||
{%- for group,spec in groups.items() %} | |||||
%{{ spec.name|default(group) }} {{ spec.get('hosts', ['ALL'])|join(',') }}=({{ spec.get('runas', ['ALL'])|join(', ') }}) {% if spec.get('nopasswd', True) %}NOPASSWD: {% endif %}{{ spec.get('commands', ['ALL'])|join(', ') }} | %{{ spec.name|default(group) }} {{ spec.get('hosts', ['ALL'])|join(',') }}=({{ spec.get('runas', ['ALL'])|join(', ') }}) {% if spec.get('nopasswd', True) %}NOPASSWD: {% endif %}{{ spec.get('commands', ['ALL'])|join(', ') }} | ||||
{%- endfor %} | {%- endfor %} | ||||
# sudoer users, file managed by salt-minion | # sudoer users, file managed by salt-minion | ||||
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | ||||
{%- for user,spec in users.iteritems() %} | |||||
{%- for user,spec in users.items() %} | |||||
{{ spec.name|default(user) }} {{ spec.get('hosts', ['ALL'])|join(',') }}=({{ spec.get('runas', ['ALL'])|join(', ') }}) {% if spec.get('nopasswd', True) %}NOPASSWD:{% endif %}{% if spec.get('setenv', False) %}SETENV:{% endif %} {{ spec.get('commands', ['ALL'])|join(', ') }} | {{ spec.name|default(user) }} {{ spec.get('hosts', ['ALL'])|join(',') }}=({{ spec.get('runas', ['ALL'])|join(', ') }}) {% if spec.get('nopasswd', True) %}NOPASSWD:{% endif %}{% if spec.get('setenv', False) %}SETENV:{% endif %} {{ spec.get('commands', ['ALL'])|join(', ') }} | ||||
{%- endfor %} | {%- endfor %} | ||||
# Sysfs file for {{ name }} managed by salt-minion(1) | # Sysfs file for {{ name }} managed by salt-minion(1) | ||||
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN | ||||
{%- for key, value in sysfs.iteritems() %} | |||||
{%- for key, value in sysfs.items() %} | |||||
{%- if key in ["mode", "owner"] %} | {%- if key in ["mode", "owner"] %} | ||||
{%- for attr, val in value.iteritems() %} | |||||
{%- for attr, val in value.items() %} | |||||
mode {{ attr }} = {{ val }} | mode {{ attr }} = {{ val }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- else %} | {%- else %} |
{%- from "linux/map.jinja" import system with context -%} | {%- from "linux/map.jinja" import system with context -%} | ||||
{%- for section, options in settings.iteritems() %} | |||||
{%- for section, options in settings.items() %} | |||||
[{{ section[0].upper() + section[1:] }}] | [{{ section[0].upper() + section[1:] }}] | ||||
{%- for option, value in options.iteritems() %} | |||||
{%- for option, value in options.items() %} | |||||
{{ option[0].upper() + option[1:] }}={{ value }} | {{ option[0].upper() + option[1:] }}={{ value }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- endfor %} | {%- endfor %} |
{%- from "linux/map.jinja" import system with context -%} | {%- from "linux/map.jinja" import system with context -%} | ||||
{%- for section, options in settings.iteritems() %} | |||||
{%- for section, options in settings.items() %} | |||||
[{{ section }}] | [{{ section }}] | ||||
{%- for option, value in options.iteritems() %} | |||||
{%- for option, value in options.items() %} | |||||
{{ option }}={{ value }} | {{ option }}={{ value }} | ||||
{%- endfor -%} | {%- endfor -%} | ||||
{%- endfor -%} | {%- endfor -%} |
type: software-system | type: software-system | ||||
relations: | relations: | ||||
{%- if system.repo is defined %} | {%- if system.repo is defined %} | ||||
{%- for repo_name, repo in system.repo.iteritems() %} | |||||
{%- for repo_name, repo in system.repo.items() %} | |||||
{%- if repo.get('enabled', True) %} | {%- if repo.get('enabled', True) %} | ||||
- service: apt.repo | - service: apt.repo | ||||
host_external: {{ repo.source }} | host_external: {{ repo.source }} |
{%- endif %} | {%- endif %} | ||||
{%- for interface_name, interface in network.interface.iteritems() if interface.get('enabled', True) %} | |||||
{%- for interface_name, interface in network.interface.items() if interface.get('enabled', True) %} | |||||
{%- if interface.type == "dpdk_ovs_bond" %} | {%- if interface.type == "dpdk_ovs_bond" %} | ||||
{%- set bond_interfaces = {} %} | {%- set bond_interfaces = {} %} | ||||
{%- for iface_name, iface in network.interface.iteritems() if iface.get('enabled', True) and iface.get('bond',"") == interface_name %} | |||||
{%- for iface_name, iface in network.interface.items() if iface.get('enabled', True) and iface.get('bond',"") == interface_name %} | |||||
{#- Get list of child interfaces #} | {#- Get list of child interfaces #} | ||||
{%- do bond_interfaces.update({iface_name: iface}) %} | {%- do bond_interfaces.update({iface_name: iface}) %} | ||||
{%- endfor %} | {%- endfor %} | ||||
linux_network_dpdk_bond_interface_{{ interface_name }}: | linux_network_dpdk_bond_interface_{{ interface_name }}: | ||||
cmd.run: | cmd.run: | ||||
- name: "ovs-vsctl add-bond {{ interface.bridge }} {{ interface_name }} {{ bond_interfaces.keys()|join(' ') }} {% for iface_name, iface in bond_interfaces.iteritems() %}-- set Interface {{ iface_name }} type=dpdk options:dpdk-devargs={{ iface.pci }} {% endfor %}" | |||||
- name: "ovs-vsctl add-bond {{ interface.bridge }} {{ interface_name }} {{ bond_interfaces.keys()|join(' ') }} {% for iface_name, iface in bond_interfaces.items() %}-- set Interface {{ iface_name }} type=dpdk options:dpdk-devargs={{ iface.pci }} {% endfor %}" | |||||
- unless: "ovs-vsctl show | grep {{ interface_name }}" | - unless: "ovs-vsctl show | grep {{ interface_name }}" | ||||
- require: | - require: | ||||
- cmd: linux_network_dpdk_bridge_interface_{{ interface.bridge }} | - cmd: linux_network_dpdk_bridge_interface_{{ interface.bridge }} |
{%- if network.mine_dns_records %} | {%- if network.mine_dns_records %} | ||||
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %} | |||||
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').items() %} | |||||
{%- if node_grains.get('dns_records', []) is iterable %} | {%- if node_grains.get('dns_records', []) is iterable %} | ||||
{%- for record in node_grains.get('dns_records', []) %} | {%- for record in node_grains.get('dns_records', []) %} | ||||
{%- set record_key = node_name ~ '-' ~ loop.index %} | {%- set record_key = node_name ~ '-' ~ loop.index %} | ||||
{%- else %} | {%- else %} | ||||
{%- for name, host in host_dict.iteritems() %} | |||||
{%- for name, host in host_dict.items() %} | |||||
{%- if host.names is defined %} | {%- if host.names is defined %} | ||||
{%- set clearers = [] %} | {%- set clearers = [] %} | ||||
{%- for etc_addr, etc_names in salt.hosts.list_hosts().iteritems() %} | |||||
{%- for etc_addr, etc_names in salt.hosts.list_hosts().items() %} | |||||
{%- set names_to_clear = [] %} | {%- set names_to_clear = [] %} | ||||
{%- for host_name in host.names %} | {%- for host_name in host.names %} | ||||
{%- if (host.address != etc_addr) and host_name in etc_names %} | {%- if (host.address != etc_addr) and host_name in etc_names %} |
{%- endif %} | {%- endif %} | ||||
{%- for interface_name, interface in network.interface.iteritems() %} | |||||
{%- for interface_name, interface in network.interface.items() %} | |||||
{%- set interface_name = interface.get('name', interface_name) %} | {%- set interface_name = interface.get('name', interface_name) %} | ||||
- name: {{ interface_name }} | - name: {{ interface_name }} | ||||
{# add linux network interface into OVS bridge #} | {# add linux network interface into OVS bridge #} | ||||
{%- for int_name, int in network.interface.iteritems() %} | |||||
{%- for int_name, int in network.interface.items() %} | |||||
{%- set int_name = int.get('name', int_name) %} | {%- set int_name = int.get('name', int_name) %} | ||||
network.routes: | network.routes: | ||||
- name: {{ interface_name }} | - name: {{ interface_name }} | ||||
- routes: | - routes: | ||||
{%- for route_name, route in interface.route.iteritems() %} | |||||
{%- for route_name, route in interface.route.items() %} | |||||
- name: {{ route_name }} | - name: {{ route_name }} | ||||
ipaddr: {{ route.address }} | ipaddr: {{ route.address }} | ||||
netmask: {{ route.netmask }} | netmask: {{ route.netmask }} |
{%- if network.enabled and grains.get('init', None) == 'systemd' %} | {%- if network.enabled and grains.get('init', None) == 'systemd' %} | ||||
{%- if network.systemd is mapping %} | {%- if network.systemd is mapping %} | ||||
{%- for config_type, configs in network.systemd.iteritems() %} | |||||
{%- for config_type, configs in network.systemd.items() %} | |||||
{%- if config_type == 'link' %} | {%- if config_type == 'link' %} | ||||
/etc/udev/rules.d/80-net-setup-link.rules: | /etc/udev/rules.d/80-net-setup-link.rules: | ||||
- content: "" | - content: "" | ||||
{%- endif %} | {%- endif %} | ||||
{%- for config_name, config in configs.iteritems() %} | |||||
{%- for config_name, config in configs.items() %} | |||||
linux_network_systemd_networkd_{{ config_type }}_config_{{ config_name }}: | linux_network_systemd_networkd_{{ config_type }}_config_{{ config_name }}: | ||||
file.managed: | file.managed: | ||||
- name: /etc/systemd/network/{{ config_name }}.{{ config_type }} | - name: /etc/systemd/network/{{ config_name }}.{{ config_type }} |
xfsprogs: | xfsprogs: | ||||
pkg.installed | pkg.installed | ||||
{%- for disk_name, disk in storage.disk.iteritems() %} | |||||
{%- for disk_name, disk in storage.disk.items() %} | |||||
{%- set disk_name = disk.name|default(disk_name) %} | {%- set disk_name = disk.name|default(disk_name) %} | ||||
create_disk_label_{{ disk_name }}: | create_disk_label_{{ disk_name }}: |
- watch: | - watch: | ||||
- file: /etc/lvm/lvm.conf | - file: /etc/lvm/lvm.conf | ||||
{%- for vgname, vg in storage.lvm.iteritems() %} | |||||
{%- for vgname, vg in storage.lvm.items() %} | |||||
{%- if vg.get('enabled', True) %} | {%- if vg.get('enabled', True) %} | ||||
- name: {{ vg.get('name', vgname) }} | - name: {{ vg.get('name', vgname) }} | ||||
- devices: {{ vg.devices|join(',') }} | - devices: {{ vg.devices|join(',') }} | ||||
{%- for lvname, volume in vg.get('volume', {}).iteritems() %} | |||||
{%- for lvname, volume in vg.get('volume', {}).items() %} | |||||
lvm_{{ vg.get('name', vgname) }}_lv_{{ volume.get('name', lvname) }}: | lvm_{{ vg.get('name', vgname) }}_lv_{{ volume.get('name', lvname) }}: | ||||
lvm.lv_present: | lvm.lv_present: | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- endif %} | |||||
{%- endif %} |
{%- from "linux/map.jinja" import storage with context %} | {%- from "linux/map.jinja" import storage with context %} | ||||
{%- if storage.enabled %} | {%- if storage.enabled %} | ||||
{%- for swap_name, swap in storage.swap.iteritems() %} | |||||
{%- for swap_name, swap in storage.swap.items() %} | |||||
{%- if swap.enabled %} | {%- if swap.enabled %} | ||||
- linux.system.repo | - linux.system.repo | ||||
{%- endif %} | {%- endif %} | ||||
{%- for key, config in system.apt.get('config', {}).iteritems() %} | |||||
{%- for key, config in system.apt.get('config', {}).items() %} | |||||
linux_apt_conf_{{ key }}: | linux_apt_conf_{{ key }}: | ||||
file.managed: | file.managed: |
- name: ca-certificates | - name: ca-certificates | ||||
{%- if system.ca_certificates is mapping %} | {%- if system.ca_certificates is mapping %} | ||||
{%- for name, cert in system.ca_certificates.iteritems() %} | |||||
{%- for name, cert in system.ca_certificates.items() %} | |||||
{{ system.ca_certs_dir }}/{{ name }}.crt: | {{ system.ca_certs_dir }}/{{ name }}.crt: | ||||
file.managed: | file.managed: | ||||
- contents_pillar: "linux:system:ca_certificates:{{ name }}" | - contents_pillar: "linux:system:ca_certificates:{{ name }}" |
{%- if system.enabled %} | {%- if system.enabled %} | ||||
{%- for config_name, config in system.get('config', {}).iteritems() %} | |||||
{%- for config_name, config in system.get('config', {}).items() %} | |||||
{%- if config.enabled|default(True) %} | {%- if config.enabled|default(True) %} | ||||
{%- for service_name in config.pillar.keys() %} | {%- for service_name in config.pillar.keys() %} | ||||
{%- if pillar.get(service_name, {}).get('_support', {}).get('config', {}).get('enabled', False) %} | {%- if pillar.get(service_name, {}).get('_support', {}).get('config', {}).get('enabled', False) %} | ||||
{%- set support_fragment_file = service_name+'/meta/config.yml' %} | {%- set support_fragment_file = service_name+'/meta/config.yml' %} | ||||
{%- set service_config_files = load_support_file(support_fragment_file, config.pillar, config.get('grains', {}))|load_yaml %} | {%- set service_config_files = load_support_file(support_fragment_file, config.pillar, config.get('grains', {}))|load_yaml %} | ||||
{%- for service_config_name, service_config in service_config_files.config.iteritems() %} | |||||
{%- for service_config_name, service_config in service_config_files.config.items() %} | |||||
{{ service_config.path }}: | {{ service_config.path }}: | ||||
file.managed: | file.managed: | ||||
- defaults: | - defaults: | ||||
pillar: {{ config.pillar|yaml }} | pillar: {{ config.pillar|yaml }} | ||||
grains: {{ config.get('grains', {}) }} | grains: {{ config.get('grains', {}) }} | ||||
{%- for key, value in service_config.get('defaults', {}).iteritems() %} | |||||
{%- for key, value in service_config.get('defaults', {}).items() %} | |||||
{{ key }}: {{ value }} | {{ key }}: {{ value }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- if system.console is defined %} | {%- if system.console is defined %} | ||||
{%- for tty_name, console in system.console.iteritems() %} | |||||
{%- for tty_name, console in system.console.items() %} | |||||
{%- if grains.get('init', None) == 'upstart' %} | {%- if grains.get('init', None) == 'upstart' %} | ||||
{{ tty_name }}_service_file: | {{ tty_name }}_service_file: |
{%- from "linux/map.jinja" import system with context %} | {%- from "linux/map.jinja" import system with context %} | ||||
{%- for name, dir in system.directory.iteritems() %} | |||||
{%- for name, dir in system.directory.items() %} | |||||
{{ dir.name|default(name) }}: | {{ dir.name|default(name) }}: | ||||
file.directory: | file.directory: | ||||
{%- if dir %} | {%- if dir %} | ||||
{%- for key, value in dir.iteritems() %} | |||||
{%- for key, value in dir.items() %} | |||||
- {{ key }}: {{ value }} | - {{ key }}: {{ value }} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- else %} | {%- else %} |
{%- from "linux/map.jinja" import system with context %} | {%- from "linux/map.jinja" import system with context %} | ||||
{%- if system.enabled %} | {%- if system.enabled %} | ||||
{%- for file_name, file in system.file.iteritems() %} | |||||
{%- for file_name, file in system.file.items() %} | |||||
linux_file_{{ file_name }}: | linux_file_{{ file_name }}: | ||||
file.managed: | file.managed: |
{%- endif -%} | {%- endif -%} | ||||
{%- endmacro -%} | {%- endmacro -%} | ||||
{%- for group_name, group in system.group.iteritems() %} | |||||
{%- for group_name, group in system.group.items() %} | |||||
{%- if group.enabled %} | {%- if group.enabled %} | ||||
{%- endif %} | {%- endif %} | ||||
{%- for hugepages_type, hugepages in system.kernel.hugepages.iteritems() %} | |||||
{%- for hugepages_type, hugepages in system.kernel.hugepages.items() %} | |||||
{%- if hugepages.get('mount', False) or hugepages.get('default', False) %} | {%- if hugepages.get('mount', False) or hugepages.get('default', False) %} | ||||
include: | include: | ||||
- linux.system.user | - linux.system.user | ||||
{%- for name, job in system.job.iteritems() %} | |||||
{%- for name, job in system.job.items() %} | |||||
linux_job_{{ job.command }}: | linux_job_{{ job.command }}: | ||||
{%- if job.enabled|default(True) %} | {%- if job.enabled|default(True) %} |
{%- endfor %} | {%- endfor %} | ||||
{%- for module_name, module_content in system.kernel.get('module', {}).iteritems() %} | |||||
{%- for module_name, module_content in system.kernel.get('module', {}).items() %} | |||||
/etc/modprobe.d/{{ module_name }}.conf: | /etc/modprobe.d/{{ module_name }}.conf: | ||||
file.managed: | file.managed: | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- for sysctl_name, sysctl_value in system.kernel.get('sysctl', {}).iteritems() %} | |||||
{%- for sysctl_name, sysctl_value in system.kernel.get('sysctl', {}).items() %} | |||||
linux_kernel_{{ sysctl_name }}: | linux_kernel_{{ sysctl_name }}: | ||||
sysctl.present: | sysctl.present: |
{%- from "linux/map.jinja" import system with context %} | {%- from "linux/map.jinja" import system with context %} | ||||
{%- if system.enabled %} | {%- if system.enabled %} | ||||
{%- for name, limit in system.limit.iteritems() %} | |||||
{%- for name, limit in system.limit.items() %} | |||||
linux_limit_{{ name }}: | linux_limit_{{ name }}: | ||||
{%- if limit.get('enabled', True) %} | {%- if limit.get('enabled', True) %} |
{%- from "linux/map.jinja" import system with context %} | {%- from "linux/map.jinja" import system with context %} | ||||
{%- if system.enabled %} | {%- if system.enabled %} | ||||
{%- for locale_name, locale in system.locale.iteritems() %} | |||||
{%- for locale_name, locale in system.locale.items() %} | |||||
{%- if locale.get('enabled', True) %} | {%- if locale.get('enabled', True) %} | ||||
linux_locale_{{ locale_name }}: | linux_locale_{{ locale_name }}: |
{%- for motd in system.motd %} | {%- for motd in system.motd %} | ||||
{%- set motd_index = loop.index %} | {%- set motd_index = loop.index %} | ||||
{%- for name, value in motd.iteritems() %} | |||||
{%- for name, value in motd.items() %} | |||||
motd_{{ motd_index }}_{{ name }}: | motd_{{ motd_index }}_{{ name }}: | ||||
file.managed: | file.managed: | ||||
- name: /etc/update-motd.d/5{{ motd_index }}-{{ name }} | - name: /etc/update-motd.d/5{{ motd_index }}-{{ name }} |
- template: jinja | - template: jinja | ||||
{% if system.netconsole is mapping and system.netconsole.target is mapping %} | {% if system.netconsole is mapping and system.netconsole.target is mapping %} | ||||
{% for target, data in system.netconsole.target.iteritems() %} | |||||
{% for target, data in system.netconsole.target.items() %} | |||||
{% if data is mapping and data.interface is defined %} | {% if data is mapping and data.interface is defined %} | ||||
/etc/network/if-up.d/netconsole {{ target }} {{ data.interface }}: | /etc/network/if-up.d/netconsole {{ target }} {{ data.interface }}: | ||||
cmd.run: | cmd.run: |
'removed': [], | 'removed': [], | ||||
'installed': [], | 'installed': [], | ||||
} %} | } %} | ||||
{%- for name, package in system.package.iteritems() %} | |||||
{%- for name, package in system.package.items() %} | |||||
{%- if package.repo is defined or package.hold is defined or package.verify is defined %} | {%- if package.repo is defined or package.hold is defined or package.verify is defined %} | ||||
linux_extra_package_{{ name }}: | linux_extra_package_{{ name }}: | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- for pkgs_group, pkgs in pkgs_groups.iteritems() %} | |||||
{%- for pkgs_group, pkgs in pkgs_groups.items() %} | |||||
{%- if pkgs %} | {%- if pkgs %} | ||||
linux_extra_packages_{{ pkgs_group }}: | linux_extra_packages_{{ pkgs_group }}: | ||||
pkg.{{ pkgs_group }}: | pkg.{{ pkgs_group }}: |
{%- if system.profile|length > 0 %} | {%- if system.profile|length > 0 %} | ||||
{%- for name, script in system.profile.iteritems() %} | |||||
{%- for name, script in system.profile.items() %} | |||||
profile.d_script_{{ name }}: | profile.d_script_{{ name }}: | ||||
file.managed: | file.managed: | ||||
- name: /etc/profile.d/salt_profile_{{ name }}{%if name.split('.')|length == 1 %}.sh{% endif %} | - name: /etc/profile.d/salt_profile_{{ name }}{%if name.split('.')|length == 1 %}.sh{% endif %} |
{%- endif %} | {%- endif %} | ||||
{%- for name, repo in system.repo.iteritems() %} | |||||
{%- for name, repo in system.repo.items() %} | |||||
{%- set name=repo.get('name', name) %} | {%- set name=repo.get('name', name) %} | ||||
{%- if grains.os_family == 'Debian' %} | {%- if grains.os_family == 'Debian' %} | ||||
{#- os_family Redhat #} | {#- os_family Redhat #} | ||||
{%- endif %} | {%- endif %} | ||||
{#- repo.iteritems() loop #} | |||||
{#- repo.items() loop #} | |||||
{%- endfor %} | {%- endfor %} | ||||
{%- if default_repos|length > 0 and grains.os_family == 'Debian' %} | {%- if default_repos|length > 0 and grains.os_family == 'Debian' %} |
{%- from "linux/map.jinja" import system with context %} | {%- from "linux/map.jinja" import system with context %} | ||||
{%- if system.enabled %} | {%- if system.enabled %} | ||||
{%- for name, service in system.service.iteritems() %} | |||||
{%- for name, service in system.service.items() %} | |||||
linux_service_{{ name }}: | linux_service_{{ name }}: | ||||
service.{{ service.status }}: | service.{{ service.status }}: |
- require: | - require: | ||||
- pkg: linux_sysfs_package | - pkg: linux_sysfs_package | ||||
{%- for name, sysfs in system.get('sysfs', {}).iteritems() %} | |||||
{%- for name, sysfs in system.get('sysfs', {}).items() %} | |||||
/etc/sysfs.d/{{ name }}.conf: | /etc/sysfs.d/{{ name }}.conf: | ||||
file.managed: | file.managed: | ||||
- require: | - require: | ||||
- file: /etc/sysfs.d | - file: /etc/sysfs.d | ||||
{%- for key, value in sysfs.iteritems() %} | |||||
{%- for key, value in sysfs.items() %} | |||||
{%- if key not in ["mode", "owner"] %} | {%- if key not in ["mode", "owner"] %} | ||||
{%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %} | {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %} | ||||
{#- Sysfs cannot be set in docker, LXC, etc. #} | {#- Sysfs cannot be set in docker, LXC, etc. #} |
include: | include: | ||||
- linux.system.group | - linux.system.group | ||||
{%- for name, user in system.user.iteritems() %} | |||||
{%- for name, user in system.user.items() %} | |||||
{%- if user.enabled %} | {%- if user.enabled %} | ||||