This commit is contained in:
ByeonJungHun
2024-01-02 17:39:26 +09:00
parent 2bb28c35b7
commit b856e871a2
9 changed files with 33 additions and 19 deletions

View File

@@ -1,8 +1,10 @@
[defaults]
inventory = checklist
roles_path = roles
become = true
inventory = checklist
roles_path = roles
deprecation_warnings = false
display_skipped_hosts = no
ansible_home = .
ansible_home = .
stdout_callback = debug
host_key_checking = false

View File

@@ -3,8 +3,8 @@ server
nas
[server]
10.10.43.111 ansible_port=2222 ansible_user=dev2
10.10.43.112 ansible_port=2222 ansible_user=dev2
10.10.43.200 ansible_port=2222 ansible_user=dev2
10.10.43.201 ansible_port=2222 ansible_user=dev2
[nas]
10.10.43.42 ansible_port=2222 ansible_user=exemdev2
10.10.43.42 ansible_port=2222 ansible_user=exemdev2

BIN
roles/security_check/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,6 +1,6 @@
#!/bin/bash
resultfile="/tmp/$(hostname)_$(date '+%F-%H:%M').txt"
resultfile="/tmp/$(hostname).txt"
U_01() {
echo "" >> $resultfile 2>&1

View File

@@ -1,6 +1,6 @@
#!/bin/bash
resultfile="/tmp/$(hostname)_$(date '+%F-%H:%M').txt"
resultfile="/tmp/$(hostname).txt"
U_01() {
echo "" >> $resultfile 2>&1

View File

@@ -0,0 +1,12 @@
---
- name: check status
shell: |
grep -H '☆ 취약 개수 = [1-9]' *.txt | cut -d: -f1
args:
chdir: /volume1/platform/05_Security_check/
register: check_status
when: "'nas' in group_names"
- debug:
msg: "{{ check_status.stdout_lines }}"
when: "'nas' in group_names"

View File

@@ -1,2 +1,4 @@
---
- include: start.yml
- include: create_readme.yml

View File

@@ -24,24 +24,16 @@
rm -rf /tmp/ubuntu.sh
when: ansible_distribution == 'Ubuntu'
- name: File Name Search
shell: |
ls |grep {{ ansible_hostname }}
register: result
when: ansible_distribution == 'Ubuntu'
args:
chdir: /tmp/
- name: Copy Result File to Local
fetch:
src: "/tmp/{{ result.stdout }}"
src: "/tmp/{{ ansible_hostname }}.txt"
dest: "/resultdir/"
flat: yes
when: ansible_distribution == 'Ubuntu'
- name: Delete Result File
file:
path: "/tmp/{{ result.stdout }}"
path: "/tmp/{{ ansible_hostname }}.txt"
state: absent
when: ansible_distribution == 'Ubuntu'
@@ -57,4 +49,10 @@
dest: /volume1/platform/05_Security_check
with_items: "{{ copy_file.stdout_lines }}"
when: "'nas' in group_names"
- name: Delete Result File
file:
path: "/resultdir"
state: absent
delegate_to: 127.0.0.1
when: ansible_distribution == 'Ubuntu'