added second playbook

This commit is contained in:
Tanguy MAZE
2018-12-09 16:36:38 +01:00
parent ce8e53b809
commit ec233093d6
4 changed files with 85 additions and 27 deletions

View File

@@ -1,42 +1,29 @@
- name: "Initialise network config, packages & user tanguy"
hosts: roger-skyline-1
hosts: "e3r4p2.42.fr"
become: yes
become_user: root
become_method: su
tasks:
- name: "Install necessary packages"
apt:
name: ['sudo', 'mailutils', 'fail2ban']
update_cache: "yes"
state: "present"
- name: "Add tanguy to sudoers"
user:
name: "tanguy"
groups: "sudo"
append: yes
- name: "Upload firewall config"
- name: "Set up networking"
copy:
src: "files/firewall.conf"
dest: "/etc/"
src: "files/interfaces"
dest: "/etc/network/"
owner: "root"
group: "root"
- name: "Apply firewall config"
command: "iptables-restore /etc/firewall.conf"
- name: "Upload public key for tanguy"
authorized_key:
user: "tanguy"
state: "present"
key: "{{ lookup('file', '/Users/tmaze/.ssh/id_rsa.pub') }}"
- name: "Upload ssh config"
copy:
src: "files/sshd_config"
dest: "/etc/ssh/"
owner: "root"
group: "root"
- name: "Restart ssh service"
service:
name: "ssh"
state: "restarted"
enabled: yes
- name: "Upload public key for tanguy"
authorized_key:
user: "tanguy"
state: "present"
key: "{{ lookup('file', '/Users/tmaze/.ssh/id_rsa.pub') }}"
- name: "Reboot VM"
reboot:
reboot_timeout: 180