Compare commits

...

5 Commits

Author SHA1 Message Date
ac6f1eb3e3 Mise à jour de 'ct-ansible/playbook.yml' 2021-11-24 09:51:33 +01:00
DEBASTIANI
9383581c66 update 2021-11-24 09:46:41 +01:00
DEBASTIANI
a829f24463 AjoutBashHistory 2021-11-24 09:26:33 +01:00
root
8b3b3a2ad7 DsAnsibleGitea 2021-11-24 09:21:21 +01:00
bruno
0904bce7ad sisr-11-python3 2021-09-30 16:36:58 +02:00
11 changed files with 728 additions and 0 deletions

495
ct-ansible/.bash_history Normal file
View File

@ -0,0 +1,495 @@
apt install vim curl mc sudo
apt autoclean
apt autoremove
poweroff
ip a
ip l
ip n
ip r
poweroff
apt update
apt update
apt upgrade
clear
apt update
apt upgrade
clear
date
date
date
poweroff
clear
nano /etc/hosts
nano /etc/hostname
nano /etc/network/interfaces
reboot
clear
uname -r
uname -a
clear
apt update
apt upgrade
clear
apt install ansible
tail -f
clear
poweroff
apt install ansible
apt install ansible
dpkg --configure
apt install ansible
apt install ansible
clear
clear
nano ~/.ssh/config
nano /.ssh/config
nano ~/.ssh/config
nano etc/ssh/config
nano /etc/ssh/config
nano ~/.ssh/config
nano ~/.ssh/config
nano root/.ssh/config
nano /root/.ssh/config
nano /root/ssh/config
apt install ssh
nano /root/.ssh/config
nano ~/.ssh/config
lq /root/
ls /root/
ls -l
ss--keygen
ss-keygen
ssh-keygen
nano ~/.ssh/config
ssh-copy-id infra
nano ~/.ssh/config
nano /etc/hosts
nano /etc/hosts
reboot
clear
ssh-copy-id infra
ssh infra uptime
mkdir testansible
cd testansible/
nano hosts
ansible all -i hosts -m ping
ansible all -i hosts -m ping
cd
rm testansible/
rm -r testansible/
ls
cd /root
mkdir testansible
nano hosts
cd /root/testansible/
nano hosts
ansible all -i hosts -m ping
clear
cd
ssh-copy-id web1
ssh-copy-id web2
ssh infra uptime
ssh web2
clear
ssh infra uptime
cd /root/testansible/
nano hosts
cd
clear
ansible all -i hosts -m ping
cd /root/testansible/
ansible all -i hosts -m ping
ansible web -i hosts -m shell -a uptime
ssh-keygen -R 192.168.0.40
ansible web -i hosts -m shell -a uptime
ssh-keygen -R 192.168.0.30
ssh-keygen -R 192.168.0.20
clear
ansible web -i hosts -m shell -a uptime
ssh-keygen -R 192.168.0.40
ansible web -i hosts -m shell -a uptime
ssh web2
ssh web2
exit
clear
ansible web -i hosts -m shell -a uptime
cd /root/testansible/
ansible web -i hosts -m shell -a uptime
ansible web -i hosts -m shell -a uptime
ssh web2
ansible web -i hosts -m shell -a uptime
claer
clear
ansible web -i hosts -m shell -a uptime
cd /root/testansible/
ansible web -i hosts -m shell -a uptime
ssh-keygen -R 192.168.0.40
clear
ssh-keygen -R 192.168.0.40
ansible web -i hosts -m shell -a uptime
ssh web2
ansible web -i hosts -m shell -a uptime
clear
ansible web -i hosts -m shell -a uptime
ssh-keygen
ssh-keygen
clear
ssh-copy-id web2
ssh-keygen -R 192.168.0.40
ssh-copy-id web2
ssh web2
moer ../.ssh/config
more ../.ssh/config
ping web2
ssh-copy-id web2
ssh-copy-id web2
ping web2
ssh web2
nano hosts
cd
nano /root/.ssh/config
ssh-copy-id web2
ssh-keygen -R 192.168.0.31
ssh-copy-id web2
ssh infra uptime
exit
cd /tmp
cd
cd /root/tp/tpansible
ls
clear
ls
mv /tmp/squid.conf.j2 /root/tp/tpansible/
ls
ansible-playbook -i hosts squid.conf.j2
nano squid.conf.j2
exit
clear
ls
cd tp
ls
cd tpansible/
ls
nano index.html
nano web.yml
cd
clear
nano index.html
ls
cd tp
ls
cd tpansible/
ls
ip a
ls /tmp
cd /root/tp/tpansible
ls
ansible-playbook -i hosts squid.
ansible-playbook -i hosts squid.yml
nano squid.yml
nano squid.yml
ansible-playbook -i hosts squid.yml
nano squid.yml
ansible-playbook -i hosts squid.yml
nano hosts
cp hosts hosts2
nano squid.yml
cd ..
ls
cd testansible/
ls
cd ..
ls tpansible/
rm host2
rm hosts2
cd tpansible/
ls
rm hosts2
nano hosts
cd
cd /root/.ssh/
ls
nano config
cd /root/tp/tpansible/
ansible-playbook -i hosts squid.yml
ssh squid
ssh 192.168.0.225
ssh root@192.168.0.225
nano /etc/hosts
ssh squid
nano /etc/hosts
nano /root/.ssh/config
ansible-playbook -i hosts squid.yml
ssh squid
ansible-playbook -i hosts squid.yml
ssh-keygen -R 192.168.0.250
ansible-playbook -i hosts squid.yml
ssh squid
ansible-playbook -i hosts squid.yml
nano hosts
ansible-playbook -i hosts squid.yml
ssh squid
nano squid.
nano squid.yml
nano squid.yml
ansible-playbook -i hosts squid.yml
ls
more squid.yml
more hosts
ssh squid
ssh-copy-id root@squid
ssh squid
ansible-playbook -i hosts squid.yml
vim squid.yml
nano squid.yml
ansible-playbook -i hosts squid.yml
history
clear
ls
ssh squid
ansible-playbook -i hosts squid.yml
nano squid.conf.j2
ansible-playbook -i hosts squid.yml
nano squid.conf.j2
nano squid.
nano squid.yml
ls
nano web.yml
nano squid.yml
ls
mv squid.conf.j2 squid.conf
ls
nano squid.yml
nano squid.yml
ansible-playbook -i hosts squid.yml
nano squid.yml
poweroff
ip r
clear
exit
nano /etc/hosts
nano /etc/hosts
poweroff
clear
cd /root
mkdir playbook
cd playbook/
ls
nano playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano playbook.yml
o
ansible-playbook -i /etc/hosts playbook.yml
cd
ansible-playbook -i hosts playbook.yml
cd*
cd
cd playbook/
nano /hosts
ansible-playbook -i hosts playbook.yml
nano /hosts
nano /hosts
ansible-playbook -i hosts playbook.yml
nano /hosts
nano /hosts
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano /hosts
ansible-playbook -i hosts playbook.yml
nano /hosts
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
ls
nano hosts
nano /hosts
nano /hosts
nano hosts
ansible-playbook -i hosts playbook.yml
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano hosts
ansible-playbook -i hosts playbook.yml
nano hosts
nano playbook.yml
ssh-keygen -R 192.168.0.10
ssh-keygen -R 192.168.0.20
ansible-playbook -i hosts playbook.yml
ssh 192.168.0.20
ansible-playbook -i hosts playbook.yml
ssh-copy-id root@192.168.0.20 1 > /proc/sys/net/ipv4/ip_forward
ssh-copy-id root@192.168.0.20 > /proc/sys/net/ipv4/ip_forward
ssh 192.168.0.20
clear
ansible-playbook -i hosts playbook.yml
nano hosts
ansible-playbook -i hosts playbook.yml
nano hosts
ssh srv
nano hosts
ansible-playbook -i hosts playbook.yml
nano hosts
ansible-playbook -i hosts playbook.yml
nano hosts
ansible-playbook -i hosts playbook.yml
nano hosts
ansible-playbook -i hosts playbook.yml
nano hosts
apt purge wpasupplicant
nano playbook.yml
ansible-playbook -i hosts playbook.yml
nano hosts
ansible-playbook -i hosts playbook.yml --ask-pass
nano hosts
nano playbook.yml
nano playbook.yml
nano resolv.conf
ansible-playbook -i hosts playbook.yml --ask-pass
ansible-playbook -i hosts playbook.yml --ask-pass
nano resolv.conf
nano playbook.yml
ansible-playbook -i hosts playbook.yml --ask-pass
nano playbook.yml
ansible-playbook -i hosts playbook.yml --ask-pass
nano playbook.yml
ansible-playbook -i hosts playbook.yml --ask-pass
nano playbook.yml
nano playbook.yml
nano /etc/ssh/sshd_donfig
nano /etc/ssh/sshd_config
nano /etc/ssh/sshd_donfig
nano playbook.yml
nano playbook.yml
nano playbook.yml
nano hosts
ansible-lint playbook.yml
ansible-lint [playbook.yml]
ansible-lint playbook.yml ansible-playbook rds_prod.yml --syntax-check
ansible-playbook playbook.yml --syntax-check
nano playbook.yml
ansible-playbook playbook.yml --syntax-check
apt install git-core
git init
cp playbook.yml .git/
cd .git/
ls
cd ..
nano playbook.yml
ansible-playbook playbook.yml --syntax-check
clear
ls
cd .git/
ls
cd ..
mv .git/
mv .git/
mv .git/ az
ls
rm az
rm -r az
ls
clear
git clone “https://gitea.lyc-lecastel.fr/bruno.debastiani”
git clone “http://gitea.lyc-lecastel.fr/bruno.debastiani”
git clone “https://gitea.lyc-lecastel.fr/bruno.debastiani/ctansible"
;
clear
git init ctansible
ls
cd ctansible/
ls
cd ..
cp hosts ctansible/
cp playbook.yml ctansible/
cp resolv.conf ctansible/
ls
cd ctansible/
ls
git add hosts
git add playbook.yml
git add resolv.conf
git tag
bash history
cp ~/. bash_history /root/playbook/ctansible/
cp ~/.bash_history /root/playbook/ctansible/
ls
cp ~/.bash_history /root/playbook/ctansible/
ls
git add .bash_history
git clone “https://gitea.lyc-lecastel.fr/bruno.debastiani/siotp.git”
git clone ^?“https://gitea.lyc-lecastel.fr/bruno.debastiani/siotp.git”
git clone ^?https://gitea.lyc-lecastel.fr/bruno.debastiani/siotp.git
git clone https://gitea.lyc-lecastel.fr/bruno.debastiani/siotp.git
ls
clear
ls
mv siot /root/playbook/
mv siotp /root/playbook/
cd ..
ls
cp ctansible /siotp/
cp /ctansible /siotp/
mv /ctansible /siotp/
mv ct-ansible /siotp/
mv ctansible/ /siotp/
cd siotp/
ls
cd..
cd ..
ls
cd siotp/
mkdir ct-ansible
ls
cd ..
ls
cp hosts /siotp/ct-ansible/
cd siotp/
ls
cd ..
cp hosts /root/playbook/siotp/ct-ansible/
cp playbook.yml /root/playbook/siotp/ct-ansible/
cp resolv.conf /root/playbook/siotp/ct-ansible/
cd siotp/
cd ct-ansible/
ls
cd ..
git add ct-ansible/
cd ct-ansible/
git add hosts
git add playbook.yml
git add resolv.conf
clear
git tag
git commit -am DS Ansible et Gitea
git commit -am DsAnsibleGitea
git config --global user.email bruno.de.bastiani@hotmail.fr
git config --global user.name DE BASTIANI BRUNO
git config --global user.name DEBASTIANI BRUNO
git commit -am DsAnsibleGitea
cd ..
cd ..
ls
clear
git commit -am DsAnsibleGitea
cd siotp/
git commit -am DsAnsibleGitea
git push --tag
git push --tag
git show

2
ct-ansible/hosts Normal file
View File

@ -0,0 +1,2 @@
[hotes]
srv

36
ct-ansible/playbook.yml Normal file
View File

@ -0,0 +1,36 @@
---
- hosts: hotes
become: yes
become_user: root
tasks:
- name: creation de sioadm
user:
name: sioadm
state: present
groups: sudo
append: yes
password: "{{ 'sioadm' | password_hash('sha512') }}"
password_lock: yes
- name: desinstaller le paquet wpasupplicant
apt:
name: wpasupplicant
state: absent
- name: desinstaller le paquet rpcbind
apt:
name: rpcbind
state: absent
- name: ecriture fichier resolv.conf
template:
src: resolv.conf
dest: "/etc/resolv.conf"
- name: configuration sshd_config
replace:
dest: /etc/ssh/sshd_config
regexp: '^PermitRootLogin (yes|without-password)'
regexp: '^PermitRootLogin (yes|without-password|prohibit-password)'
replace: "PermitRootLogin no"

4
ct-ansible/resolv.conf Normal file
View File

@ -0,0 +1,4 @@
search sio.lan
domain sio.lan
nameserver 10.121.38.7
nameserver 10.121.38.8

32
sio2/sisr/11-python/creatusr.py Executable file
View File

@ -0,0 +1,32 @@
#!/usr/lib/python3
import sys
import subprocess
import os
nbarg = len(sys.argv)
if nbarg != 2:
print ("Nombre d'argument invalide")
exit (1)
filename = sys.argv[1]
try:
fh = open(filename, "r")
except:
print ("Fichier ", filename," inconnu")
exit (2)
else:
line = fh.readline ()
while line:
nouvline = line.rstrip()
login,nomlong = nouvline.split(':')
cmd = "sudo useradd -m -d /home/"+login+" -c \'"+ no$
res = os.system ("getent passwd "+login)
if res != 0:
passw = "pwgen 4 1"
os.system (cmd)
os.system ("pwgen 4 1")
os.system ("echo "+login+passw"|chpasswd)
os.system ("echo "login+passw" >> "+filename+".p$
else:
print ("Utilisateur "+login+" déjà éxistant")
line = fh.readline()
fh.close()

View File

@ -0,0 +1,33 @@
#!/usr/lib/python3
import sys
import subprocess
import os
nbarg = len(sys.argv)
if nbarg != 2:
print ("Nombre d'argument invalide")
exit (1)
filename = sys.argv[1]
try:
fh = open(filename, "r")
except:
print ("Fichier ", filename," inconnu")
exit (2)
else:
line = fh.readline ()
while line:
nouvline = line.rstrip()
login,nomlong = nouvline.split(':')
cmd = "sudo useradd -m -d /home/"+login+" -c \'"+ no$
res = os.system ("getent passwd "+login)
if res != 0:
passw = "pwgen 4 1"
os.system (cmd)
os.system ("pwgen 4 1")
os.system ("echo "+login+passw+"|chpasswd")
os.system ("echo "+login+passw+" >> "+filename+"$
else:
print ("Utilisateur "+login+" déjà éxistant")
os.system ("sudo userdel -r "+login)
line = fh.readline()
fh.close()

8
sio2/sisr/11-python/ex1.py Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/python3
p = 3.141592
rayon = int(input("Quel est le diametre du cercle ?"))
resultat = 2*p*rayon
print("Le rayon du cercle est de " , resultat)

28
sio2/sisr/11-python/ex2.py Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/python3
i = 0
maxi = i
mini = i
total = 0
tab = []
for i in range (5) :
valeur = int(input("Quelle sont les valeurs du tableau ?"))
tab.append(valeur)
maxi = valeur
mini = valeur
for valeur in tab :
if valeur < mini :
mini = valeur
if valeur > maxi :
maxi = valeur
total = total + valeur
moyenne = total/5
print("Le plus grand element est :" , maxi)
print("Le plus petit element est :" , mini)
print("La moyenne est : " , moyenne)
for valeur in tab :
print (valeur)

14
sio2/sisr/11-python/ex3.py Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/python3
phrase = input("Phrase : ")
tabmot=phrase.split (' ')
cptmot={}
for mot in tabmot:
if mot in cptmot:
cptmot[mot]=cptmot[mot]+1
else :
cptmot[mot]=1
for cle in cptmot.keys():
print(cle, cptmot[cle])

34
sio2/sisr/11-python/ex4.py Executable file
View File

@ -0,0 +1,34 @@
#!/usr/lib/python3
import sys
import subprocess
import os
nbarg = len(sys.argv)
if nbarg != 2:
print ("Nombre d'argument invalide")
exit (1)
filename = sys.argv[1]
try:
fh = open(filename, "r")
except:
print ("Fichier ", filename," inconnu")
exit (2)
else:
line = fh.readline ()
while line:
nouvline = line.rstrip()
login,nomlong = nouvline.split(':')
cmd = "sudo useradd -m -d /home/"+login+" -c \'"+ nomlong+"\' -s /bin/bash "+ login
res = os.system ("getent passwd "+login)
if res != 0:
passw = "pwgen 4 1"
os.system (cmd)
mdp = string(os.system ("pwgen 4 1"))
os.system ("echo "+login+mdp+"|chpasswd")
os.system ("echo "+login+mdp+" > "+filename+".pwd")
else:
print ("Utilisateur "+login+" déjà éxistant")
os.system ("sudo userdel -r "+login)
line = fh.readline()
fh.close()

42
sio2/sisr/11-python/passusr.py Executable file
View File

@ -0,0 +1,42 @@
#!/usr/lib/python3
import sys
import subprocess
import os
nbarg = len(sys.argv)
if nbarg != 2:
print ("Nombre d'argument invalide")
exit (1)
filename = sys.argv[1]
try:
fh = open(filename, "r")
except:
print ("Fichier ", filename," inconnu")
exit (2)
else:
line = fh.readline ()
while line:
nouvline = line.rstrip()
login,nomlong = nouvline.split(':')
cmd = "sudo useradd -m -d /home/"+login+" -c \'"+ no$
res = os.system ("getent passwd "+login)
if res != 0:
passw = ["pwgen", "4","1"]
#passw = "pwgen 4 1"
os.system (cmd)
#mdp = str(os.system (passw))
#print (mdp)
mdp = subprocess.run(passw,capture_output=True)
mdp2 = mdp.stdout.decode("utf-8")
mdp3 = mdp2.rstrip()
print (mdp3)
ch3 = "echo "+login+":"+mdp3+"|sudo chpasswd"
print (ch3)
os.system (ch3)
os.system ("sudo echo "+login+":"+mdp3+" >> "+fi$
else:
print ("Utilisateur "+login+" déjà éxistant")
os.system ("sudo userdel -r "+login)
line = fh.readline()
fh.close()