配置管理

您可以使用配置文件和通道管理客户端的配置,而无需手动配置每个客户端。

配置参数编写在脚本中并存储在配置文件中。您可以使用 SUSE Multi-Linux Manager Web UI 直接写入配置文件,也可以上载或关联到其他位置存在的文件。

配置通道用于组织配置文件。您可以为客户端订阅配置通道,并根据需要部署配置文件。

配置文件有版本控制,因此您可以添加配置设置,在您的客户端上对其进行测试,并根据需要将其回滚到之前的修订版。如果您已创建配置通道,还可以在不同的配置文件以及同一配置文件的不同修订版之间进行比较。

Configuration files are provided through Configuration Channels or State Channels.

下表显示了支持的功能,其中:

  • 功能受 SUSE 支持

  • 功能不受 SUSE 支持

  • 功能正在考虑之中,日后可能受支持,也可能不受支持。

Table 1. 配置管理支持的功能
Feature Status

Config Channels

State Channels

Deploying Files

Comparing Files

Applying the Highstate

File Import from a Client

Jinja Templating

1. Create configuration channels

1.1. Configuration channel

To create a new configuration channel:

Procedure: Creating a configuration channel
  1. 在 SUSE Multi-Linux Manager Web UI 中,导航到配置  通道,然后单击 创建配置通道

  2. 键入通道的名称。

  3. 键入通道的标签。 This field must contain only letters, numbers, hyphens (-) and underscores (_).

  4. 键入用于与其他通道进行区分的通道说明。

  5. 单击 创建配置通道 以创建新通道。

1.2. State channel

State channels use Salt states on clients:

Procedure: Creating a Salt state channel
  1. 在 SUSE Multi-Linux Manager Web UI 中,导航到配置  通道,然后单击 创建状态通道

  2. 键入通道的名称。

  3. 键入通道的标签。 This field must contain only letters, numbers, hyphens (-) and underscores (_).

  4. 键入用于与其他通道进行区分的通道说明。

  5. Type the SLS Contents for the init.sls file.

  6. Click Create Config State Channel to create the new channel.

如果您已创建配置通道,则可以添加配置文件、目录或符号链接:

Procedure: Adding a configuration file, directory, or symbolic link
  1. 在 SUSE Multi-Linux Manager Web UI 中,导航到配置  通道,单击要向其添加配置文件的配置通道的名称,然后导航到添加文件  创建文件子选项卡。

  2. In the File Type field, choose whether you want to create a text file, directory, or symbolic link.

  3. In the Filename/Path field, type the absolute path to the location where the file should be deployed.

  4. If you are creating a symbolic link, type the target file and path in the Symbolic Link Target Filename/Path field.

  5. Type the User name and Group name for the file in the Ownership field, and the File Permissions Mode.

  6. If the client has SELinux enabled, you can configure SELinux contexts to enable the required file attributes (for example: user, role, and file type).

  7. You can use Jinja templating with grains or pillar data instead of legacy macro delimiters.

  8. Enter the configuration file contents in the File Contents text box, using the script drop-down box to choose the appropriate scripting language.

  9. 单击 创建配置文件

3. Subscribe clients to configuration channels

You can subscribe individual clients to configuration channels by navigating to Systems  System List, selecting the client you want to subscribe, and navigating to the Configuration tab. To subscribe multiple clients to a configuration channel, you can use the system set manager (SSM).

Procedure: Subscribing multiple clients to configuration channels
  1. 在 SUSE Multi-Linux Manager Web UI 中,导航到系统  系统列表,然后选择要使用的客户端。

  2. 导航到系统  系统集管理器,然后转到配置  订阅通道子选项卡,以查看可用配置通道的列表。

  3. OPTIONAL: Click the number in the Systems currently subscribed column to see which clients are currently subscribed to the configuration channel.

  4. 选中要订阅的配置通道,然后单击 继续

  5. 使用向上和向下箭头对配置通道排名。 两个配置通道之间的设置发生冲突时,系统会优先使用更靠近列表顶部的通道。

  6. 确定通道应用到所选客户端的方式。 单击 订阅为最低优先级 可将新通道添加为比目前订阅的通道都低的优先级。单击 订阅为最高优先级 可将新通道添加为比目前订阅的通道都高的优先级。单击 替换现有订阅 可去除现有通道并将其替换为新通道。

  7. 单击 应用订阅

如果新配置通道优先级与现有通道冲突,系统会去除重复的通道并根据新优先级进行替换。如果某个操作要对客户端的配置优先级重新排序,Web UI 会要求您在继续之前先确认更改。

4. Compare configuration files

您也可以使用系统集管理器 (SSM) 将客户端上部署的配置文件与存储在 SUSE Multi-Linux Manager 服务器上的配置文件进行比较。

Procedure: Comparing configuration files
  1. 在 SUSE Multi-Linux Manager Web UI 中,导航到系统  系统列表,然后选择订阅了要比较的配置文件的客户端。

  2. 导航到系统  系统集管理器,然后转到配置  比较文件子选项卡,以查看可用配置文件的列表。

  3. OPTIONAL: Click the number in the Systems column to see which clients are currently subscribed to the configuration file.

  4. 选中要比较的配置文件,然后单击 安排文件比较

5. 在客户端上建立 Jinja 模板

Jinja templating is possible on Salt clients. Jinja is only evaluated when content is processed by the Salt engine. Jinja provides variables from pillars or grains. They can be used in files managed by Salt (for example, via file.managed) or Salt states.

File configuration channels deliver static files without Jinja processing. State channel files are only applied if referenced in a Salt state.

有关详细信息,请参见 https://docs.saltproject.io/salt/user-guide/en/latest/topics/jinja.html,该页面包含以下示例:

{% if grains.os_family == 'RedHat' %}
  {% set dns_cfg = '/etc/named.conf' %}
{% elif grains.os_family == 'Debian' %}
  {% set dns_cfg = '/etc/bind/named.conf' %}
{% else %}
  {% set dns_cfg = '/etc/named.conf' %}
{% endif %}
dns_conf:
  file.managed:
    - name: {{ dns_cfg }}
    - source: salt://dns/files/named.conf
    - template: jinja