Repository navigation
Expand file tree
/
Copy pathREADME
More file actions
146 lines (115 loc) · 4.81 KB
/
Copy pathREADME
File metadata and controls
146 lines (115 loc) · 4.81 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# RANCiD docker container #
 |
 |
 |
 |

## Description ##
This will actually pull the latest release from https://github.com/haussli/rancid build it and install it.
Adaptations has been done to make it easier to manage outside the docker instance but some things has to done inside the instance to make it work!
## Build/Pull ##
Build locally from a cloned git repository
```
git pull https://github.com/paddy01/rancid-git.git rancid
cd rancid
docker build \
--build-arg UID=<current_user_id:default=1000> \
--build-arg GID=<current_group_id:default=1000> \
--build-arg TIMEZONE='<your_time_zone:default=UTC>' \
-t ipforpat/rancid-git .
```
(not tested)
or from docker hub
```
docker pull ipforpat/rancid-git
```
(works but not recommended if you wish to modify uid,gid and timezone)
or Docker Compose using github as base
```
version: "3"
services:
rancid:
image: ipforpat/rancid-git
build:
context: https://github.com/paddy01/rancid-git.git
args:
UID: <current_user_id:default=1000>
GID: <current_group_id:default=1000>
TIMEZONE: '<your_time_zone:default=UTC>'
volumes:
- type: bind
source: <directory_where_you_want_global_configurations>
target: /etc/rancid
- type: bind
source: <directory_where_you_want_rancid_specific_configurations_and_repos>
target: /home/rancid
```
(this is the recommended - and tested - method if you expect to modify uid, gid and/or timezone with ease)
## RUN ##
```
mkdir -p <directory_where_you_want_rancid_specific_configurations_and_repos>
mkdir -p <directory_where_you_want_global_configurations>
docker run -d --name rancid-git -v <directory_where_you_want_global_configurations>:/etc/rancid \
-v <directory_where_you_want_rancid_specific_configurations_and_repos>:/home/rancid ipforpat/rancid-git
```
or Docker Compose simply
```
docker-compose up -d
```
## SETUP ##
This isn't very slick, please feel free to improve on this!
You'll need to add some devices which you want the configs backed up from for this app to be useful!
```
echo 'LIST_OF_GROUPS="devices"; export LIST_OF_GROUPS' >> <directory_where_you_want_global_configurations>/rancid.conf
```
Get a shell on the container:
```
docker exec -itu rancid rancid-git bash
```
or via Docker Compose
```
docker-compose exec -u rancid rancid bash
```
Whenever adding groups, run rancid-cvs which creates the required folders and
initial git repository for your device group. This will create a
<directory_where_you_want_rancid_specific_configurations_and_repos>/var/GROUPNAME/ folder structure containing the git repository. Do
this as the rancid user so file ownership is set correctly.
```
docker exec -itu rancid rancid-git rancid-cvs
```
with Docker Compose
```
docker-compose exec -u rancid rancid rancid-cvs
```
Add login details for your devices to the .cloginrc file
```
echo -e 'add user * USERNAME\nadd password * PASSWORD ENABLEPASS\nadd method * ssh telnet\nadd cyphertype * {aes256-cbc}\n' >> <directory_where_you_want_rancid_specific_configurations_and_repos>/.cloginrc
```
or edit .cloginrc in <directory_where_you_want_rancid_specific_configurations_and_repos>
Add devices into the list of devices to probe
```
echo device1:cisco:up >> <directory_where_you_want_rancid_specific_configurations_and_repos>/var/devices/router.db
echo device2:juniper:up >> <directory_where_you_want_rancid_specific_configurations_and_repos>/var/devices/router.db
```
Perform an initial run to check it all works!
```
docker exec -itu rancid rancid-run
```
or with Docker Compose
```
docker-compose exec -u rancid rancid rancid-run
```
Logs for any errors in <directory_where_you_want_rancid_specific_configurations_and_repos>/var/logs/devices._yyyymmdd.hhmmss_
Check config grabs have appeared into <directory_where_you_want_rancid_specific_configurations_and_repos>/var/devices/configs/_hostname_
Check cron is running as per <directory_where_you_want_global_configurations>/rancid.cron file.
## VOLUMES ##
* /home/rancid - rancid working directory, logs and device configurations go here
* /etc/rancid - rancid main configuration and cron file
## ISSUES ##
* Email output of logs fails, as there's no local SMTP server on this container.
* might want to map /etc/hosts file in so hostname to IP mappings can be stored in there
## CREDITS ##
* This is an adaptation of the work done by biwhite
- some texts are directly copied from biwhite's work
## LICENSE ##
Please read the LICENSE file