diff --git a/projets/netseclab/ansible/ansible.cfg b/projets/netseclab/ansible/ansible.cfg new file mode 100644 index 0000000000000000000000000000000000000000..321fe5ba58822c3b56f8f331e75b16a733cb8f49 --- /dev/null +++ b/projets/netseclab/ansible/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +stdout_callback=debug \ No newline at end of file diff --git a/projets/netseclab/ansible/create_user_wst-01-08.yml b/projets/netseclab/ansible/create_user_wst-01-08.yml new file mode 100644 index 0000000000000000000000000000000000000000..c0c3e6d9caefb5e65a6cbce9b7ef2f60918134da --- /dev/null +++ b/projets/netseclab/ansible/create_user_wst-01-08.yml @@ -0,0 +1,12 @@ +- hosts: wst-01-08 + gather_facts: true + vars_prompt: + - name: password + prompt: What is the new password? + + tasks: + - name: change user's password + become: true + ansible.builtin.user: + name: agodomou + password: '{{password}}' diff --git a/projets/netseclab/ansible/create_user_wst-09-16.yml b/projets/netseclab/ansible/create_user_wst-09-16.yml new file mode 100644 index 0000000000000000000000000000000000000000..5108a5d6aef0761897c347f8c0ebf5a8c63d3735 --- /dev/null +++ b/projets/netseclab/ansible/create_user_wst-09-16.yml @@ -0,0 +1,12 @@ +- hosts: wst-09-16 + gather_facts: true + vars_prompt: + - name: password + prompt: What is the new password? + + tasks: + - name: change user's password + become: true + ansible.builtin.user: + name: lavorel + password: '{{password}}' diff --git a/projets/netseclab/ansible/hosts b/projets/netseclab/ansible/hosts new file mode 100644 index 0000000000000000000000000000000000000000..c3b1043c07c35cc2d076bb7d8554454666d87bbc --- /dev/null +++ b/projets/netseclab/ansible/hosts @@ -0,0 +1,49 @@ +[wst] +wst-01 ansible_host=10.78.240.1 +wst-02 ansible_host=10.78.240.2 +wst-03 ansible_host=10.78.240.3 +wst-04 ansible_host=10.78.240.4 +wst-05 ansible_host=10.78.240.5 +wst-06 ansible_host=10.78.240.6 +wst-07 ansible_host=10.78.240.7 +wst-08 ansible_host=10.78.240.8 +wst-09 ansible_host=10.78.240.9 +wst-10 ansible_host=10.78.240.10 +wst-11 ansible_host=10.78.240.11 +wst-12 ansible_host=10.78.240.12 +wst-13 ansible_host=10.78.240.13 +wst-14 ansible_host=10.78.240.14 +wst-15 ansible_host=10.78.240.15 +wst-16 ansible_host=10.78.240.16 + +[wst-01-08] +wst-01 ansible_host=10.78.240.1 +wst-02 ansible_host=10.78.240.2 +wst-03 ansible_host=10.78.240.3 +wst-04 ansible_host=10.78.240.4 +wst-05 ansible_host=10.78.240.5 +wst-06 ansible_host=10.78.240.6 +wst-07 ansible_host=10.78.240.7 +wst-08 ansible_host=10.78.240.8 + +[wst-09-16] +wst-09 ansible_host=10.78.240.9 +wst-10 ansible_host=10.78.240.10 +wst-11 ansible_host=10.78.240.11 +wst-12 ansible_host=10.78.240.12 +wst-13 ansible_host=10.78.240.13 +wst-14 ansible_host=10.78.240.14 +wst-15 ansible_host=10.78.240.15 +wst-16 ansible_host=10.78.240.16 + +[wst:vars] +ansible_port=22 +ansible_ssh_common_args='-o StrictHostKeyChecking=no' + +[wst-01-08:vars] +ansible_port=22 +ansible_ssh_common_args='-o StrictHostKeyChecking=no' + +[wst-09-16:vars] +ansible_port=22 +ansible_ssh_common_args='-o StrictHostKeyChecking=no' diff --git a/projets/netseclab/ansible/initial_setup.yml b/projets/netseclab/ansible/initial_setup.yml new file mode 100644 index 0000000000000000000000000000000000000000..8b7d51109443f42f9980dfdf63d1e66d09abca08 --- /dev/null +++ b/projets/netseclab/ansible/initial_setup.yml @@ -0,0 +1,17 @@ +- hosts: wst + gather_facts: true + vars_prompt: + - name: password + prompt: What is the new password? + + tasks: + - name: change user's password + become: true + ansible.builtin.user: + name: debian + password: '{{password}}' + - name: Update and upgrade apt packages + become: true + ansible.builtin.apt: + upgrade: yes + update_cache: yes diff --git a/projets/netseclab/ansible/shutdown.yml b/projets/netseclab/ansible/shutdown.yml new file mode 100644 index 0000000000000000000000000000000000000000..0fd5e09d8a23336faf5ddf3d4e4a28d031615f90 --- /dev/null +++ b/projets/netseclab/ansible/shutdown.yml @@ -0,0 +1,7 @@ +- hosts: wst + gather_facts: true + + tasks: + - name: Unconditionally shut down the machine with all defaults + become: true + community.general.shutdown: diff --git a/projets/netseclab/create_user_wst-01-08.sh b/projets/netseclab/create_user_wst-01-08.sh new file mode 100755 index 0000000000000000000000000000000000000000..e876128f9d7b1ee134f176342d7524b74c1ca8cf --- /dev/null +++ b/projets/netseclab/create_user_wst-01-08.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# first argument of the scrit is ansible username + +cd ansible +ansible-playbook create_user_wst-01-08.yml -u $1 -i hosts -kK diff --git a/projets/netseclab/create_user_wst-09-16.sh b/projets/netseclab/create_user_wst-09-16.sh new file mode 100755 index 0000000000000000000000000000000000000000..65e393f1a9101d337ec891182d55ef8d81e6faf5 --- /dev/null +++ b/projets/netseclab/create_user_wst-09-16.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# first argument of the scrit is ansible username + +cd ansible +ansible-playbook create_user_wst-09-16.yml -u $1 -i hosts -kK diff --git a/projets/netseclab/hosts.txt b/projets/netseclab/hosts.txt new file mode 100644 index 0000000000000000000000000000000000000000..a1af16a58b5c9502d15714d44857042777c7401f --- /dev/null +++ b/projets/netseclab/hosts.txt @@ -0,0 +1,16 @@ +10.78.240.1 +10.78.240.2 +10.78.240.3 +10.78.240.4 +10.78.240.5 +10.78.240.6 +10.78.240.7 +10.78.240.8 +10.78.240.9 +10.78.240.10 +10.78.240.11 +10.78.240.12 +10.78.240.13 +10.78.240.14 +10.78.240.15 +10.78.240.16 diff --git a/projets/netseclab/initial_setup.sh b/projets/netseclab/initial_setup.sh new file mode 100755 index 0000000000000000000000000000000000000000..3f92df04129f649ca16f29c78f80ec51e6f47430 --- /dev/null +++ b/projets/netseclab/initial_setup.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# first argument of the scrit is ansible username + +cd ansible +ansible-playbook initial_setup.yml -u $1 -i hosts -kK diff --git a/projets/netseclab/ping.sh b/projets/netseclab/ping.sh new file mode 100755 index 0000000000000000000000000000000000000000..f0905b001ec6f47cecda3479e5dc757969524490 --- /dev/null +++ b/projets/netseclab/ping.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# File containing the list of hosts, one per line +HOSTS_FILE="hosts.txt" + +# ANSI color codes +GREEN='\033[0;32m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +# Check if the hosts file exists +if [[ ! -f "$HOSTS_FILE" ]]; then + echo "Hosts file not found!" + exit 1 +fi + +# Read the hosts file and ping each host +while IFS= read -r host; do + if ping -c 1 -W 1 "$host" &> /dev/null; then + echo -e "Host ${GREEN}$host${NC} is reachable." + else + echo -e "Host ${RED}$host${NC} is not reachable." + fi +done < "$HOSTS_FILE" diff --git a/projets/netseclab/shutdown.sh b/projets/netseclab/shutdown.sh new file mode 100755 index 0000000000000000000000000000000000000000..77dfd5f27c71bede050579b7a08b2a968e20ad36 --- /dev/null +++ b/projets/netseclab/shutdown.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# first argument of the scrit is ansible username + +cd ansible +ansible-playbook shutdown.yml -u $1 -i hosts -kK