LoginSignup
18
20

More than 5 years have passed since last update.

【連載01】205.SELinuxを無効化する【Ansible SELinuxモジュール】

Last updated at Posted at 2016-01-26

当記事はケーススタディの連載となっています。目次は【こちら】です。
最新のソースコードは【GitHub】で公開中です。
サーバの責務はこちらで確認ください。

1.SELinux無効化概要

SELinuxを無効化する。

image

2.playbookファイルの相関

image

3.playbook(site.yml)

${ANSIBLE_HOME}/site.yml
メインとなるplaybook(site.yml)参照

4.SELinux無効化用のplaybook(/operations/0021_selinux.yml)

${ANSIBLE_HOME}/operations/0021_selinux.yml

# ===================
# SELinuxを無効化する(selinux.yml)
# ===================
# ===================
# すべてのサーバのSELinuxを無効化する
# ===================
- hosts: all
  sudo: no
  remote_user: root
  tasks:

    - name: SELinuxのDisable設定
      selinux: state=disabled
【SELinuxモジュール】SELinuxの無効化設定

selinuxモジュールを使用する。

書式:

selinux: state=${enforcing または permissive またはdisabled}

state 状態
enforcing アクセス制限有効
permissive 警告はするがアクセス制限はしない
disabled 無効化する

例:
SELinuxを無効化する。

selinux: state=disabled

disable設定はLinux上でsetenforceコマンドでラベル付けはできない。
Ansibleも同様に起動時に無効化設定されるため、次の章ではAnsibleにて再起動する。

※Ansible(Python)でSELinuxの操作をするにはlibselinux-pythonパッケージが必要。
今回は「yumにて必要なライブラリ/ミドル/ソフトウェアをインストールする」にて先にインストールしているが、本来であればincludeしたファイル単位で冪等性を維持しつつ、凝縮度の高いplaybookを作った方が独立性が高くなる。
その場合先にyumモジュールを使用してlibselinux-pythonをインストールしておくとよい。

  tasks:
#▼ここに追加
    - name: Install libselinux-python
      yum: name=libselinux-python state=present
#▲

    - name: SELinuxのDisable設定
      selinux: state=disabled

次回は「SELinux設定Diabledを適用する為サーバを再起動する【Ansible 非同期処理】」について。

連載の目次は【こちら】です。

18
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
20