-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote.py
58 lines (50 loc) · 1.32 KB
/
remote.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import subprocess
os.system("sudo clear")
os.system("tput setaf 3")
print("Remote")
os.system("tput setaf 7")
while True:
os.system("tput setaf 4")
print("""
1.Check Ansible connectivity
2.Configure Web server
3.Httpd authentication
4.Add user
5.Yum configration with dvd
6.Back
""")
os.system("tput setaf 7")
cmd=int(input("Enter your choice \t"))
if cmd==1:
print(subprocess.getoutput("ansible all -m ping"))
elif cmd==2:
print(subprocess.getoutput('ansible all -m package -a "name=httpd state=present "'))
print(subprocess.getoutput('ansible all -m service -a "name=httpd state=started" '))
elif cmd==3:
subprocess.getoutput('ansible-playbook httpserver_auth.yml')
elif cmd==4:
ip=input("Enter remote ip\t")
user=input("Enter user name\t")
pas=input("Enter your passwd\t")
y=subprocess.getstatusoutput("ping -w 2 {}".format(ip))
if y[0]==0:
file= open("inventory.txt",'a')
st="\n{} ansible_user={} ansible_ssh_pass={} ansible_connection=ssh".format(ip,user,pas)
file.write(st)
file.close()
cmd="ssh root@{} date".format(ip)
os.system(cmd)
else:
print("Invaild IP")
elif cmd==5:
os.system("ansible-playbook yum.yml")
elif cmd==6:
exit()
else :
print("Not found")
input()
os.system("clear")
os.system("tput setaf 3")
print("\t\t\tRemote")
os.system("tput setaf 7")