Ansible制御ノードのセットアップ

Ansible制御ノードをセットアップするには、SUSE Multi-Linux Manager Web UIから次のステップを実行します。

To configure a client as the Ansible Control Node, the Ansible package must be installed on that system. Usually, the Ansible package should be obtained from the operating system vendor’s official repositories. For example, on SUSE Linux Enterprise 15 SP6 and SP7, Ansible is available through the Systems Management Module.

プロシージャ: SUSE Linux Enterprise 15 SP6またはSP7システムでのAnsible制御ノードのセットアップ
  1. In the SUSE Multi-Linux Manager Web UI, navigate to Admin  Setup Wizard  Products, verify that SUSE Linux Enterprise Server 15 SP6 x86_64 (or later) with the Systems Management Module and the required Python 3 Module are selected and synchronized.

  2. SUSE Linux Enterprise 15 SP6 (またはそれ以降)のクライアントを配備します。

  3. In the SUSE Multi-Linux Manager Web UI, navigate to the Systems  Overview page of the client. Select Software  Software Channels and subscribe the client to the SUSE Linux Enterprise Server 15 SP6 x86_64 (or later SP), Systems Management Module and Python 3 Module channels.

  4. Select Details  Properties of your client. From the Add-On System Types list enable Ansible Control Node and click Update Properties.

  5. クライアントの概要ページに移動し、状態  highstateを選択して、highstateの適用をクリックします。

  6. イベントタブを選択して、highstateの状態を確認します。

If you want to install a newer Ansible on a SUSE Linux Enterprise 15 SP4 or SP5 client, you must enable the Python 3 Module.

Ansibleの新しいバージョンでは、古いPythonバージョンを搭載したノードの管理はサポートされなくなりました。 管理対象ノードが依然として古いPythonバージョンをデフォルトとして設定している場合、playbookの実行中に接続エラーや障害が発生する可能性があります。 これに対処するには、可能であれば管理対象ノードのPythonをアップグレードし、Ansibleのインベントリまたは設定で正しいPythonインタープリタを設定する必要があります。

1. Ansibleインベントリファイルの作成

Ansible統合ツールは、playbookをインベントリファイルとして配備します。 表1に一覧表示されている個々のオペレーティングシステムごとに1つのインベントリファイルを作成します。

プロシージャ: Ansibleインベントリファイルの作成
  1. Create and add your hosts to an inventory file to be managed by Ansible. The default path for an Ansible inventory is /etc/ansible/hosts.

    Listing 1. インベントリの例
    client240.mgr.example.org
    client241.mgr.example.org
    client242.mgr.example.org
    client243.mgr.example.org ansible_ssh_private_key_file=/etc/ansible/some_ssh_key
    
    [mygroup1]
    client241.mgr.example.org
    client242.mgr.example.org
    
    [mygroup2]
    client243.mgr.example.org
    
    [all:vars]
    ansible_ssh_public_key_file=/etc/ansible/my_ansible_private_key
  2. In the SUSE Multi-Linux Manager Web UI, from the Ansible tab navigate to Ansible  Control Node to add inventory files to the control node.

  3. Under the Playbook Directories section add /usr/share/scap-security-guide/ansible to the Add a Playbook Directories field and click Save.

  4. Under Inventory Files add your inventory file locations to the Add an Inventory file field and click Save.

    Listing 2. 例
    /etc/ansible/sles15
    /etc/ansible/sles12
    /etc/ansible/centos7

    その他のplaybookの例については、https://github.com/ansible/ansible-examplesを参照してください。

プロシージャ: Ansibleノードとの通信の確立
  1. インベントリで使用しているSSHキーを作成します。

    ssh-keygen -f /etc/ansible/my_ansible_private_key
  2. 生成されたSSHキーをAnsible管理対象クライアントにコピーします。 例:

    ssh-copy-id -i /etc/ansible/my_ansible_public_key root@client240.mgr.example.org
  3. Declare the private key in /etc/ansible/ansible.cfg as follows:

    private_key_file = /etc/ansible/my_ansible_private_key

    Replace my_ansible_private_key with the name of the file containing the private key.

  4. 制御ノードから次のコマンドを実行して、Ansibleが動作していることをテストします。

    ansible all -m ping
    ansible mygroup1 -m ping
    ansible client240.mgr.example.org -m ping

これで修復を実行できます。詳細については、コードとしてのコンプライアンスを参照してください。