test push
This commit is contained in:
8
ansible.cfg
Normal file
8
ansible.cfg
Normal file
@@ -0,0 +1,8 @@
|
||||
[defaults]
|
||||
inventory = checklist
|
||||
roles_path = roles
|
||||
deprecation_warnings = False
|
||||
display_skipped_hosts = no
|
||||
ansible_home = .
|
||||
stdout_callback = debug
|
||||
host_key_checking = False
|
||||
10
checklist
Normal file
10
checklist
Normal file
@@ -0,0 +1,10 @@
|
||||
[all:children]
|
||||
server
|
||||
nas
|
||||
|
||||
[server]
|
||||
10.10.43.111 ansible_port=2222 ansible_user=dev2
|
||||
10.10.43.112 ansible_port=2222 ansible_user=dev2
|
||||
|
||||
[nas]
|
||||
10.10.43.42 ansible_port=2222 ansible_user=exemdev2
|
||||
2
roles/security_check/defaults/main.yml
Normal file
2
roles/security_check/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# defaults file for security_check
|
||||
3768
roles/security_check/files/rocky.sh
Normal file
3768
roles/security_check/files/rocky.sh
Normal file
File diff suppressed because it is too large
Load Diff
3701
roles/security_check/files/ubuntu.sh
Normal file
3701
roles/security_check/files/ubuntu.sh
Normal file
File diff suppressed because it is too large
Load Diff
2
roles/security_check/tasks/main.yml
Normal file
2
roles/security_check/tasks/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- include: start.yml
|
||||
60
roles/security_check/tasks/start.yml
Normal file
60
roles/security_check/tasks/start.yml
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
- name: Create Result Directory
|
||||
file:
|
||||
path: /resultdir
|
||||
state: directory
|
||||
delegate_to: 127.0.0.1
|
||||
when: "'nas' in group_names"
|
||||
|
||||
- name: Old Result File Delete
|
||||
shell: |
|
||||
rm -rf /volume1/platform/05_Security_check/*
|
||||
when: "'nas' in group_names"
|
||||
|
||||
- name: Copy Security Check Script
|
||||
copy:
|
||||
src: "{{ role_path }}/files/ubuntu.sh"
|
||||
dest: /tmp/ubuntu.sh
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
|
||||
- name: Start Security Check Script
|
||||
shell: |
|
||||
chdir
|
||||
bash /tmp/ubuntu.sh
|
||||
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 }}"
|
||||
dest: "/resultdir/"
|
||||
flat: yes
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
|
||||
- name: Delete Result File
|
||||
file:
|
||||
path: "/tmp/{{ result.stdout }}"
|
||||
state: absent
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
|
||||
- name: Find Copy File Name
|
||||
shell: ls -l /resultdir/ | awk 'NR>1 {print $9}'
|
||||
register: copy_file
|
||||
delegate_to: 127.0.0.1
|
||||
when: "'nas' in group_names"
|
||||
|
||||
- name: Copy Result File to NAS
|
||||
copy:
|
||||
src: "/resultdir/{{ item }}"
|
||||
dest: /volume1/platform/05_Security_check
|
||||
with_items: "{{ copy_file.stdout_lines }}"
|
||||
when: "'nas' in group_names"
|
||||
|
||||
2
roles/security_check/vars/main.yml
Normal file
2
roles/security_check/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for security_check
|
||||
6
server_check.yml
Normal file
6
server_check.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- hosts: all
|
||||
become: true
|
||||
gather_facts: true
|
||||
roles:
|
||||
- role: security_check
|
||||
Reference in New Issue
Block a user