반응형
ansible-playbook-openssl 정보 조회
pkg-lookup-openssl.yaml edit
vim pkg-lookup-openssl.yaml
---
- name: openssl 정보 조회
hosts: all
become: true
gather_facts: yes
tasks:
- name: openssl 버전 정보 조회
shell: openssl version
register: result_output
- debug:
var: result_output.stdout
- name: result.txt 파일에 openssl 버전 정보 출력
lineinfile:
path: /tmp/result.txt
# line: "{{ ansible_date_time.iso8601 }} - {{ item }} / {{ hostvars[item].ansible_default_ipv4.address }} : {{ result_output.stdout_lines }}"
line: "{{ lookup('pipe', 'date +\"%Y.%m.%d %H:%M:%S KST\"') }} - {{ item }} / {{ hostvars[item].ansible_default_ipv4.address }} : {{ result_output.stdout_lines }}"
state: present
create: yes
loop: "{{ query('inventory_hostnames', 'all') }}"
시스템에서 타임스템프(timestamp) 가져와서 사용하였다
---
- name: openssl 정보 조회
hosts: all
become: true
gather_facts: yes
tasks:
- name: openssl 버전 정보 조회
shell: openssl version
register: result_output
- debug:
var: result_output.stdout
- name: 시스템에서 타임스탬프 가져오기(timestamp)
shell: "date '+%Y.%m.%d %H:%M:%S KST' --date '-12 hour ago'"
register: tstamp_output
- debug:
var: tstamp_output.stdout
- name: result.txt 파일에 openssl 버전 정보 출력
lineinfile:
path: /tmp/result.txt
# line: "{{ ansible_date_time.iso8601 }} - {{ item }} / {{ hostvars[item].ansible_default_ipv4.address }} : {{ result_output.stdout_lines }}"
line: "{{ tstamp_output.stdout_lines }} - {{ item }} / {{ hostvars[item].ansible_default_ipv4.address }} : {{ result_output.stdout_lines }}"
# line: "{{ lookup('pipe', 'date +\"%Y.%m.%d %H:%M:%S KST\"') }} - {{ item }} / {{ hostvars[item].ansible_default_ipv4.address }} : {{ result_output.stdout_lines }}"
state: present
create: yes
loop: "{{ query('inventory_hostnames', 'all') }}"
ansible-playbook 실행
ansible-playbook -i ./inventory pkg-lookup-openssl.yaml
$ ansible-playbook -i ./inventory pkg-lookup-openssl.yaml
PLAY [openssl 정보 조회] *********************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************
ok: [kube-node1]
ok: [kube-control1]
TASK [openssl 버전 정보 조회] ****************************************************************************************
changed: [kube-control1]
changed: [kube-node1]
TASK [debug] *********************************************************************************************************
ok: [kube-control1] => {
"result_output.stdout": "OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)"
}
ok: [kube-node1] => {
"result_output.stdout": "OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)"
}
TASK [result.txt 파일에 openssl 버전 정보 출력] **********************************************************************
changed: [kube-control1] => (item=kube-control1)
changed: [kube-node1] => (item=kube-control1)
changed: [kube-control1] => (item=kube-node1)
changed: [kube-node1] => (item=kube-node1)
PLAY RECAP ***********************************************************************************************************
kube-control1 : ok=4 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
kube-node1 : ok=4 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
결과 파일(/tmp/result.txt)
$ cat /tmp/result.txt
2022.11.03 00:47:01 KST - kube-control1 / 192.168.0.51 : ['OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)']
2022.11.03 00:47:02 KST - kube-node1 / 192.168.0.61 : ['OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)']
728x90
반응형
'리눅스' 카테고리의 다른 글
파이썬 가상 환경을 구성하고 설정하는 방법(python virtual environment) (0) | 2022.11.03 |
---|---|
CentOS 7에 Python 3와 pip3를 설치하기 (0) | 2022.11.03 |
ansible-playbook 명령어 (0) | 2022.11.02 |
[Ansible] ansible-playbook apache(httpd) install (0) | 2022.11.02 |
앤서블 플레이북 키워드 (0) | 2022.11.02 |