[](https://www.hongsnet.net) # Ansible을 이용한 보안취약점 조치 > 접속 시 사용자 패스워드의 missmatch count를 제한하고, Block을 수행하는 pam_tally2 모듈을 적용한다. ## Inventory 설정 ```bash # cat hosts [ALL_HOSTS] 172.16.0.100 managed_ip=172.16.0.100 des="2020-12-03" [ALL_HOSTS_OK] ``` 대상 호스트는 172.16.0.100이며, 추가는 2020-12-03에 수행한다. 참고적으로 **ALL_HOSTS_OK** 호스트 그룹은 작업이 완료된 호스트의 history를 위한 그룹이다. ## Host Variables 설정 ```bash # cat host_vars/172.16.0.100 ansible_ssh_host: 172.16.0.100 ansible_ssh_port: SSH_포트번호 ansible_ssh_user: 사용자 아이디 ansible_ssh_pass: "사용자 패스워드" ansible_become: yes ansible_become_method: su ansible_become_user: root ansible_become_pass: "!root_패스워드" ansible_python_interpreter: python2.7 ``` ## Playbook 설정 ```python --- - name: OS Secure Fix hosts: ALL_HOSTS tasks: - name: Account Pam_tally2 Setting lineinfile: path: /etc/pam.d/common-auth insertbefore: BOF regexp: "pam_tally2.so" line: "auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900" when: ansible_distribution == "Debian" - name: Account Pam_tally2 Setting lineinfile: dest: '/etc/pam.d/system-auth' regexp: "pam_tally2.so" line: "auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900" state: present when: ansible_distribution == "CentOS" ``` `보안취약점 조치`에 대한 Playbook 분석 * [ ] OS 별 설정을 Facts 변수(ansible_distribution)로 구분하여, 적용한다. ## playbook 실행 ```bash # ansible-playbook -i hosts pam_tally2.yml ```