Added host templates + new firewall rules

This commit is contained in:
Tanguy MAZE
2018-12-13 18:12:18 +01:00
parent af72857616
commit 2fd6ee2186
6 changed files with 84 additions and 8 deletions

View File

@@ -0,0 +1,2 @@
{{ ansible_nodename }} ansible_host={{ ansible_default_ipv4.address }} ansible_port=2230 ansible_user=tanguy
roger-skyline-1 ansible_host=192.168.99.2 ansible_port=2230 ansible_user=tanguy

37
templates/init.yml.j2 Normal file
View File

@@ -0,0 +1,37 @@
- name: "Initialise network config, packages & user tanguy"
hosts: {{ ansible_nodename }}
become: yes
become_user: root
become_method: su
tasks:
- name: "Set up networking"
copy:
src: "files/interfaces"
dest: "/etc/network/"
owner: "root"
group: "root"
- name: "Upload ssh config"
copy:
src: "files/sshd_config"
dest: "/etc/ssh/"
owner: "root"
group: "root"
- name: "Install sudo"
apt:
name: ['sudo']
update_cache: "yes"
state: "present"
- name: "Add tanguy to sudoers"
user:
name: "tanguy"
groups: "sudo"
append: yes
- name: "Upload public key for tanguy"
authorized_key:
user: "tanguy"
state: "present"
key: "{{ lookup('file', '/Users/tmaze/.ssh/id_rsa.pub') }}"
- name: "Restart networking service"
service:
name: "networking"
state: "restarted"