Added basic Linux server prestage playbook + reboot playbook

This commit is contained in:
Vlad Raducanu
2022-05-06 22:03:49 +01:00
parent 26f5d909cc
commit 8efdffa137
6 changed files with 128 additions and 40 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
all:
hosts:
172.16.1.112
172.16.1.112:
-17
View File
@@ -1,17 +0,0 @@
---
- hosts: all
roles:
- common
become: yes
tasks:
- name: Update apt cache and install required packages
apt:
name: "{{ item }}"
update_cache: yes
loop:
- curl
- tree
- syslog-ng
- vsftpd
- tftpd-hpa
+76
View File
@@ -0,0 +1,76 @@
---
- name: Prestage server and install services [SYSLOG, FTP, TFTP, NTP]
hosts: all
roles:
- common
become: yes
tasks:
- name: Update and upgrade current packages
apt:
update_cache: yes
upgrade: yes
- name: Update apt cache and install required packages
apt:
name: "{{ item }}"
loop:
- curl
- tree
- syslog-ng
- vsftpd
- tftpd-hpa
- ntp
- ufw
- name: Create a new regular user with sudo privileges
user:
name: "{{ create_user }}"
state: present
groups: sudo
append: true
create_home: true
shell: /bin/bash
- name: Set authorized key for remote user
authorized_key:
user: "{{ create_user }}"
state: present
key: "{{ copy_local_key }}"
- name: Configure UFW to allow inbound NTP, SSH, SYSLOG, FTP connections
ufw:
rule: allow
direction: in
port: "{{ item.port }}"
proto: "{{ item.proto }}"
loop:
- port: '22'
proto: tcp
- port: '123'
proto: udp
- port: '514'
proto: udp
- port: '23'
proto: tcp
- name: UFW - Deny all other incoming traffic by default
ufw:
state: enabled
policy: deny
direction: incoming
- name: Block all IPv6 incoming connections
ufw:
rule: block
direction: in
proto: ipv6
- name: Send Webex Teams message via BOT to confirm playbook completion
community.general.cisco_webex:
recipient_type: toPersonEmail
recipient_id: "{{ webex_id }}"
msg_type: markdown
personal_token: "{{ webex_token }}"
msg: "**Prestaging has been completed for host {{ inventory_hostname }}.**"
+14
View File
@@ -0,0 +1,14 @@
---
- name: Reboots linux host and checks status
hosts: all
roles:
- common
become: yes
tasks:
- name: Rebooting...
reboot:
reboot_timeout: 60
msg: Reboot issued by Ansible
test_command: whoami
+24 -9
View File
@@ -1,10 +1,25 @@
$ANSIBLE_VAULT;1.1;AES256
30663731353038306664656333313032613039636134333435383762613735666562653432323363
6637363832633337623436396163333237613534373033340a623362313361313565636332343363
63343838656334373730303139616466323061383338343939313662356466646465333363666662
3233376264313864300a323830666635323838643530393436393736323336343138383332323365
38623962633165316262633963323461376530393133646532376561396130313565646663633766
65373538393233373633393031323137323462343938323262636439663133323237303335616563
64656262353931393635396361343131356632623836393835616462653439353734366461323432
35373562306261666330663162613731363263623034623463646662346335366239306366626239
3030
64393466643139323164303532333865626432353430346466643432613664363962666137373861
3138323435393937373239386136626436346462383965630a376366316130376631633339636531
39643138323166313131313533643662363731316532633664326634373434356338343533653866
6234346535343362390a393666626362313763346362663837376664663762656339393430353132
64313164323630363637353230643834303164333665376437623235613264363965623530666236
61643430333861376334373061643239386566316561373531333862626163386261643636313531
39616637306466636462323337393239653135633962623965346134623262613236366438336264
38326265666363643166363565636534633061643165646239663565363434323561633235353663
65306636333664666361396638613634353166313430646462623633306239376331303066656536
65623939306564613037613263343537623933653761303139323033633066393665393236366635
36316462643231363832303233316461643330346435326263666337363435333833656632656231
39636638313336613135653830396262366330636266653333336433316637626634306236393033
65313061303066643566306133663830633136366633303665633332613432616237373161613338
65643266336330393936663461386464386262323638343365313136326137373661363161633730
30323630363038636462653737386232343562376433646435663335376562346466313863656330
34363731636163396465653830303263393937633332333937633434343732343234386536653832
31663535333732363736656138663163333861376365333632656266626161616166373537623166
35626161383336333835336364653135356437353535373765383337326261303037373964356330
33346264343736663866363639363766373435363137326638366636613464636637666432333331
33383238323537656565393066373034346664396339366564343261643765343865353361393961
34633538653333343234366332613739383738306462366139666537343965613465623236333733
34656239393537656532383061383861623235323664663837356137333736316132383334363138
37643363333636303935373461653436333436323439323662373731383536383662353637383664
32366363333437323161