0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ansible lintAdvent Calendar 2022

Day 12

【ルール説明】partial-become

Last updated at Posted at 2022-12-31

こちらの記事は Ansible lint Advent Calendar 2022 カレンダー2 12日目の記事になります。

今回はルール partial-become について説明します。

partial-become

partial-become はユーザーを変更して権限を昇格させる時にbecome: trueディレクティブが記述されているか検証し違反している場合は警告を出力します。

例えば処理を実行するユーザーが変更先のユーザーより強い権限を与えられていればbecome: trueディレクティブの付与は必要ないように見えます。(例: Ansible を root で実行、処理の途中でapacheにユーザー変更し httpd をリロードする)しかし不必要な混乱を避けるためにbecomebecome_userは同時に利用します。

問題のあるコード

---
- name: Example playbook
  hosts: localhost
  tasks:
    - name: Start the httpd service as the apache user
      ansible.builtin.service:
        name: httpd
        state: started
        become_user: apache # <- become:true が記述されていない

修正されたコード

- name: Example playbook
  hosts: localhost
  tasks:
    - name: Start the httpd service as the apache user
      ansible.builtin.service:
        name: httpd
        state: started
        become: true # <- become: true を記述する
        become_user: apache

参考サイト

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?