NTSU-163 - server post in Ansible
**Objective:** Create a server test web in Ansible and use the 4 tools (Post, ansible, Terraform, Uz) in this process to perform.
---
### (1) Use `Post` to create the server test web
**Steps:**
1. Use `Post` to create a new server test web.
2. Implement the functionality that continuously listens and responds to client machine requests.
3. Alternatively, use `Post` to continuously send requests to the test web.
**Script:**
```python
import socket
import time
def client_server():
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('0.0.0.0', 8000))
server.listen(0)
while True:
try:
client, addr = server.accept()
print('1 req', client, addr)
client.send(b'Hello World
')
client.close()
except (socket,ConnectionError,):
server.quit()
time.sleep(1)
server = socket.socket(socket.AF, socket.SOCK_STream)
server.bind(("0.0.0.0", 8000))
server.listen(0)
print("new 2 iterations")
else:
print("new 2 iterations")
```
---
### (2 Use `ansible` to create the server test web
**Steps:**
1. Use `ansible` to create a new server test web.
2. Implement the functionality that continuously listens and responds to client machine requests.
3. Alternatively, use `ansible` to continuously send requests to the test web.
**Scks:**
```python
import socket
import time
import socket. (socket AF_INET, socket.SOCK_STREAM)
def client_server():
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind('0.0.0.0', 8000)
server.listen(0)
while True:
try:
client, addr = server.accept()
print('1 req', client, addr)
client.send(b'Hello World
')
client.close()
except (socket,connectionError,):
server.quit()
time.sleep(1)
server = socket.socket(socket.AF, socket.SOCK_STREAM)
server.bind(('0.0.0.0', 8000))
server.listen(0)
print('new 2 iterations')
else:
print('new 2 iterations')
```
---
### (3 Use `terraform` to create the server test web
**Steps:**
1.Use `terraform` to create a new server test web.
2. Implement the functionality that continuously listens and responds to client machine requests.
3. Alternatively, use `terraform` to continuously send requests to the test web.
**So**
**ro:**
```python
import socket
import time
import socket. (socket AF_INET, socket.SOCK_STREAM)
def client_server():
server = socket.socket(socket.AF_INET, socket.SOCK_ST
> server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind('0.0.0.0', 8000)
server.listen(0)
while True:
try:
client, addr = server.accept()
print('1 req', client, addr)
client.send(b'Hello Worldln')
client.close()
except (socket,connectionError,):
server.quit()
time.sleep(1)
server = socket.socket(socket.AF, socket.SOCK_STREAM)
server.bind('0.0.0.0', 8000)
server.listen(0)
print('new 2 iterations')
else:
print('new 2 iterations')
```
---
### (3 Use `Uz` to create the server test web
**Steps:**
1. Use `Uz` to create a new server test web.
2. Implement the functionality that continuously listens and responds to client machine requests.
3. Alternatively, use `Uz` to continuously send requests to the test web.
**Scks:**
```python
import socket
import time
import socket. (socket AF_INET, socket.SOCK_STREAM)
def client_server():
server = socket.socket(socket.AF, socket.SOCK_STREAM)
server.bind('0.0.0.0', 8000)
server.listen(0)
while True:
try:
client, addr = server.accept()
print('1 req', client, addr)
client.send(b'Hello World
')
client.close()
except (socket,connectionError,):
server.quit()
time.sleep(1)
server = socket.socket(socket.AF, socket.SOCK_STREAM)
server.bind('0.0.0.0', 8000)
server.listen(0)
print('new 2 iterations')
else:
print('new 2 iterations')
```
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>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