11.6. Ansible을 사용하여 위임 규칙에 특정 속성이 없는지 확인

다음 절차에서는 위임 규칙에 특정 설정이 없도록 Ansible 플레이북을 사용하는 방법을 설명합니다. 이 플레이북을 사용하여 위임 역할에 바람직하지 않은 액세스 권한이 부여되지 않도록 할 수 있습니다. 이 예제에서는 기본 관리자 속성 의 위임 규칙에 staff number 및 employee type 멤버 속성이 없는지 확인합니다.

사전 요구 사항

  • IdM 관리자 암호를 알고 있습니다.
  • 다음 요구 사항을 충족하도록 Ansible 제어 노드를 구성했습니다.

    • Ansible 버전 2.14 이상을 사용하고 있습니다.
    • Ansible 컨트롤러에 ansible-freeipa 패키지가 설치되어 있습니다.
    • 이 예제에서는 ~/MyPlaybook/ 디렉터리에서 IdM 서버의 FQDN(정규화된 도메인 이름)을 사용하여 Ansible 인벤토리 파일을 생성했다고 가정합니다.
    • 이 예제에서는 secret.yml Ansible 자격 증명 모음이 ipaadmin_password 를 저장한다고 가정합니다.
  • IdM에 기본 관리자 속성 의 위임 규칙이 있습니다.

절차

  1. ~/MyPlaybooks/ 디렉터리로 이동합니다.

    $ cd ~/MyPlaybooks/
  2. /usr/share/doc/ansible-freeipa/playbooks/delegation/ 디렉터리에 있는 delegation-member-absent.yml 파일을 복사합니다.

    $ cp /usr/share/doc/ansible-freeipa/playbooks/delegation/delegation-member-absent.yml delegation-member-absent-copy.yml
  3. 편집할 delegation-member-absent-copy.yml Ansible 플레이북 파일을 엽니다.
  4. ipadelegation 작업 섹션에서 다음 변수를 설정하여 파일을 조정합니다.

    • ipaadmin_password 변수를 IdM 관리자의 암호로 설정합니다.
    • name 변수를 수정할 위임 규칙의 이름으로 설정합니다.
    • 특성 변수를 worker number 및 employee type 로 설정합니다.
    • action 변수를 member 로 설정합니다.
    • state 변수를 absent 로 설정합니다.

    현재 예제에 대해 수정된 Ansible 플레이북 파일입니다.

    ---
    - name: Delegation member absent
      hosts: ipaserver
    
      vars_files:
      - /home/user_name/MyPlaybooks/secret.yml
      tasks:
      - name: Ensure delegation "basic manager attributes" member attributes employeenumber and employeetype are absent
        ipadelegation:
          ipaadmin_password: "{{ ipaadmin_password }}"
          name: "basic manager attributes"
          attribute:
          - employeenumber
          - employeetype
          action: member
          state: absent
  5. 파일을 저장합니다.
  6. Ansible 플레이북을 실행합니다. 플레이북 파일, secret.yml 파일을 보호하는 암호를 저장하는 파일 및 인벤토리 파일을 지정합니다.

    $ ansible-playbook --vault-password-file=password_file -v -i ~/MyPlaybooks/inventory delegation-member-absent-copy.yml

추가 리소스

  • 분류 규칙을 참조하십시오.
  • /usr/share/doc/ansible-freeipa/ 디렉터리에서 README-delegation.md 파일을 참조하십시오.
  • /usr/share/doc/ansible-freeipa/playbooks/ipadelegation 디렉토리에서 샘플 플레이북을 참조하십시오.