Skip to content
Snippets Groups Projects
Commit 3302ba5b authored by Pierre Kunzli's avatar Pierre Kunzli
Browse files

ajout de contenu pour les clusters k8s

parent 72621b30
Branches
No related tags found
No related merge requests found
[defaults]
stdout_callback=debug
\ No newline at end of file
- 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}}'
- 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}}'
[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'
- 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
- hosts: wst
gather_facts: true
tasks:
- name: Unconditionally shut down the machine with all defaults
become: true
community.general.shutdown:
#!/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
#!/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
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
#!/bin/bash
# first argument of the scrit is ansible username
cd ansible
ansible-playbook initial_setup.yml -u $1 -i hosts -kK
#!/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"
#!/bin/bash
# first argument of the scrit is ansible username
cd ansible
ansible-playbook shutdown.yml -u $1 -i hosts -kK
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment