Skip to content

Commit 5b320b9

Browse files
edit README example
1 parent ffc9169 commit 5b320b9

File tree

1 file changed

+109
-4
lines changed

1 file changed

+109
-4
lines changed

README.md

Lines changed: 109 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ The `codespaces-node-scan` it's scanner can be used in CI to detect host availab
88

99
## example usage
1010

11-
help
11+
### help
1212

1313
`docker run -i --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest --help`
1414

15-
output
15+
### output
1616

1717
```bash
1818
Node-scan CI component usage:
@@ -22,11 +22,13 @@ Scan example range hosts and port: codespaces-node-scan 192.168.0.2-254 80
2222
Scan example range hosts and ports: codespaces-node-scan 192.168.0.27-192.168.0.254 22-443
2323
```
2424

25-
scan host and port
25+
---
26+
27+
### scan host and port
2628

2729
`docker run -i --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest 8.8.8.8 53`
2830

29-
output
31+
### output
3032

3133
```json
3234
[
@@ -42,6 +44,109 @@ output
4244
]
4345
```
4446

47+
---
48+
49+
### Use for .gitlab-ci.yml
50+
51+
```yml
52+
---
53+
default:
54+
cache:
55+
key: "${CI_COMMIT_REF_SLUG}"
56+
paths:
57+
- configs
58+
59+
stages:
60+
- check_port
61+
62+
services:
63+
- name: docker:dind
64+
65+
variables:
66+
DOCKER_HOST: tcp://docker:2376
67+
DOCKER_DRIVER: overlay2
68+
DOCKER_TLS_CERTDIR: "/certs"
69+
70+
SCAN_NET: 10.10.20.1-254
71+
SCAN_PORT: 23
72+
73+
gitlab:get_router:
74+
stage: check_port
75+
tags:
76+
- service_dontainer_dind
77+
script:
78+
- apk add jq
79+
- docker run -i --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest ${SCAN_NET} ${SCAN_PORT} | jq -r '.[] | select(.ip) | .ip' > configs/available.ip
80+
- cat configs/available.ip
81+
```
82+
83+
### optput pipeline
84+
85+
```bash
86+
10.10.20.3
87+
10.10.20.57
88+
10.10.20.44
89+
10.10.20.1
90+
10.10.20.55
91+
10.10.20.48
92+
10.10.20.21
93+
10.10.20.30
94+
```
95+
96+
---
97+
98+
### This can be used for ansible to form a inventories/hosts.yml file in text task.
99+
100+
```yml
101+
gitlab:lint:
102+
stage: ansible_play
103+
image: ghcr.io/rootshell-coder/ansible:latest
104+
tags:
105+
- service_dontainer_dind
106+
script:
107+
- |+
108+
echo "---" > inventories/hosts.yml
109+
echo "all:" >> inventories/hosts.yml
110+
echo " children:" >> inventories/hosts.yml
111+
echo " keenetic:" >> inventories/hosts.yml
112+
echo " hosts:" >> inventories/hosts.yml
113+
while IFS= read -r ip; do
114+
echo " ${ip}:" >> inventories/hosts.yml
115+
done < configs/available.ip
116+
- ansible-lint -q --offline
117+
- cat inventories/hosts.yml
118+
```
119+
120+
### optput pipeline
121+
122+
```yaml
123+
---
124+
all:
125+
children:
126+
dynamic:
127+
hosts:
128+
10.10.20.3:
129+
10.10.20.57:
130+
10.10.20.44:
131+
10.10.20.1:
132+
10.10.20.55:
133+
10.10.20.48:
134+
10.10.20.21:
135+
10.10.20.30:
136+
```
137+
138+
_It remains only to perform Play (ansible-playbook -i inventories/hosts.yml ...) Is it really just?_
139+
140+
---
141+
142+
### Perhaps there are a thousand more ways to use this
143+
144+
```bash
145+
echo "Other usage"
146+
```
147+
148+
---
149+
45150
## build
46151

47152
```bash

0 commit comments

Comments
 (0)