Skip to content

Commit d006026

Browse files
committed
Initial commit, moved cf-remote from core
Signed-off-by: Ole Herman Schumacher Elgesem <oleherman93@gmail.com>
0 parents  commit d006026

File tree

16 files changed

+2632
-0
lines changed

16 files changed

+2632
-0
lines changed

README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# cf-remote
2+
3+
## Installation
4+
5+
cf-remote requires python 3 with fabric and requests.
6+
(Install using brew/apt/yum/pip).
7+
It's a _normal_ python package, but doesn't have a setup script (yet).
8+
9+
Clone `cfengine/core` repo where you want, and then symlink, like this:
10+
11+
```
12+
$ git clone https://github.com/cfengine/core.git
13+
$ ln -s `pwd`/core/contrib/cf-remote/cf_remote/__main__.py /usr/local/bin/cf-remote
14+
```
15+
16+
Install dependencies:
17+
18+
```
19+
$ cd core/contrib/cf-remote/
20+
$ pip3 install -r requirements.txt
21+
```
22+
23+
Check that it worked:
24+
25+
```
26+
$ ls -al `which cf-remote`
27+
lrwxr-xr-x 1 olehermanse admin 68 Jan 10 15:20 /usr/local/bin/cf-remote -> /northern.tech/cfengine/core/contrib/cf-remote/cf_remote/__main__.py
28+
$ cf-remote --version
29+
cf-remote version 0.1 (BETA)
30+
Available CFEngine versions:
31+
3.13.0, 3.12.1, 3.12.0, 3.10.5, 3.10.4, 3.10.3, 3.10.2, 3.10.1, 3.10.0
32+
```
33+
34+
Note that the version/branch of core you have checked out is important!
35+
You can also move it out of your core folder if you prefer this (but then making changes to cf-remote becomes more tedious).
36+
37+
## Examples
38+
39+
### See information about remote host
40+
41+
The `info` command can be used to check basic information about a system.
42+
43+
```
44+
$ cf-remote info -H 34.241.203.218
45+
46+
ubuntu@34.241.203.218
47+
OS : ubuntu (debian)
48+
Architecture : x86_64
49+
CFEngine : 3.12.1
50+
Policy server : 172.31.42.192
51+
Binaries : dpkg, apt
52+
```
53+
54+
(You must have ssh access).
55+
56+
### Installing and bootstrapping CFEngine Enterprise Hub
57+
58+
The `install` command can automatically download and install packages as well as bootstrap both hubs and clients.
59+
60+
```
61+
cf-remote install --hub 34.247.181.100 --bootstrap 172.31.44.146 --demo
62+
63+
ubuntu@34.247.181.100
64+
OS : ubuntu (debian)
65+
Architecture : x86_64
66+
CFEngine : Not installed
67+
Policy server : None
68+
Binaries : dpkg, apt
69+
70+
Package already downloaded: '/Users/olehermanse/.cfengine/cf-remote/packages/cfengine-nova-hub_3.12.1-1_amd64.deb'
71+
Copying: '/Users/olehermanse/.cfengine/cf-remote/packages/cfengine-nova-hub_3.12.1-1_amd64.deb' to '34.247.181.100'
72+
Installing: 'cfengine-nova-hub_3.12.1-1_amd64.deb' on '34.247.181.100'
73+
CFEngine 3.12.1 was successfully installed on '34.247.181.100'
74+
Bootstrapping: '34.247.181.100' -> '172.31.44.146'
75+
Bootstrap successful: '34.247.181.100' -> '172.31.44.146'
76+
Transferring def.json to hub: '34.247.181.100'
77+
Copying: '/Users/olehermanse/.cfengine/cf-remote/json/def.json' to '34.247.181.100'
78+
Triggering an agent run on: '34.247.181.100'
79+
Disabling password change on hub: '34.247.181.100'
80+
Triggering an agent run on: '34.247.181.100'
81+
Your demo hub is ready: https://34.247.181.100/ (Username: admin, Password: password)
82+
```
83+
84+
Note that this demo setup (`--demo`) is notoriously insecure.
85+
It has default passwords and open access controls.
86+
Don't use it in a production environment.
87+
88+
### Specify an SSH key
89+
90+
If you have more than one key in `~/.ssh` you may need to specify which key `cf-remote` is to use.
91+
92+
```
93+
$ export CF_REMOTE_SSH_KEY="~/.ssh/id_rsa.pub"
94+
```
95+
96+
## Contribute
97+
98+
Feel free to open pull requests to expand this documentation, add features or fix problems.
99+
You can also pick up an existing task or file an issue in [our bug tracker](https://tracker.mender.io/issues/?filter=11711).
100+
`cf-remote` is a part of the [cfengine community repo](https://github.com/cfengine/core) and has the same license (GPLv3).

cf_remote/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
3+
files = os.listdir(__path__[0])
4+
modules = (x.replace(".py", "") for x in files if x.endswith(".py") and not x.startswith("__"))
5+
for module in modules:
6+
__import__("cf_remote." + module)

cf_remote/__main__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python3
2+
if __name__ == "__main__":
3+
import os
4+
import sys
5+
6+
above_dir = os.path.dirname(os.path.realpath(__file__)) + "/../"
7+
abspath = os.path.abspath(above_dir)
8+
sys.path.insert(0, abspath)
9+
10+
from cf_remote.main import main
11+
main()

cf_remote/cloud_data.py

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
aws_platforms = {
2+
'ubuntu-20-04-x64':{
3+
'ami':'ami-0aef57767f5404a3c',
4+
'user':'ubuntu',
5+
'size':'t2.small',
6+
'xlsize':'t3.xlarge',
7+
},
8+
'ubuntu-18-04-x64':{
9+
'ami':'ami-0ee3436f275c4f2e8',
10+
'user':'ubuntu',
11+
'size':'m1.small',
12+
'xlsize':'m3.xlarge',
13+
},
14+
'ubuntu-14-04-x32':{
15+
'ami':'ami-07a1e6256cb43b99c',
16+
'user':'ubuntu',
17+
'size':'m1.small'
18+
},
19+
'debian-8-x64':{
20+
'ami':'ami-402f1a33',
21+
'user':'admin',
22+
'size':'t1.micro',
23+
'xlsize':'m3.xlarge',
24+
},
25+
'debian-7-x64':{
26+
'ami':'ami-61e56916',
27+
'user':'admin',
28+
'size':'t1.micro',
29+
'xlsize':'m3.xlarge',
30+
},
31+
'debian-9-x64':{
32+
'ami':'ami-035c67e6a9ef8f024',
33+
'user':'admin',
34+
'size':'t1.micro',
35+
'xlsize':'m3.xlarge',
36+
},
37+
'debian-10-x64':{
38+
'ami':'ami-0a9d04ba7d4df6c3b',
39+
'user':'admin',
40+
'size':'t1.micro',
41+
'xlsize':'m3.xlarge',
42+
},
43+
'centos-6-x64':{
44+
'ami':'ami-05bd23226cb7c2896',
45+
'user':'centos',
46+
'size':'t2.micro',
47+
'xlsize':'m3.xlarge',
48+
},
49+
'centos-7-x64':{
50+
'ami':'ami-0f4775c518fa29365',
51+
'user':'centos',
52+
'size':'t2.micro',
53+
'xlsize':'m3.xlarge',
54+
},
55+
"rhel-5-x64": {
56+
"ami": "ami-ea94369d",
57+
"size": "t1.micro",
58+
"user": "root",
59+
"xlsize": "t1.micro"
60+
},
61+
"rhel-6-x64": {
62+
"ami": "ami-c1bb06b2",
63+
"size": "t2.micro",
64+
"user": "ec2-user",
65+
"xlsize": "t2.large"
66+
},
67+
"rhel-7-x64": {
68+
"ami": "ami-065ec1e661d619058",
69+
"size": "t2.micro",
70+
"user": "ec2-user",
71+
"xlsize": "t2.large"
72+
},
73+
"rhel-8-x64": {
74+
"ami": "ami-08f4717d06813bf00",
75+
"size": "t3a.micro",
76+
"user": "ec2-user",
77+
"xlsize": "m3.xlarge"
78+
},
79+
"coreos": {
80+
"ami": "ami-067301c1a68e593f5",
81+
"size": "t3a.nano",
82+
"user": "core"
83+
},
84+
'centos-5-x32':{
85+
'ami':'ami-fe11398a',
86+
'user':'root',
87+
'size':'m1.small'
88+
},
89+
'debian-6-x64':{
90+
'ami':'ami-879e4ff0',
91+
'user':'admin',
92+
'size':'t1.micro'
93+
},
94+
'debian-5-x32':{
95+
'ami':'ami-8398b3f7',
96+
'user':'root',
97+
'size':'m1.small'
98+
},
99+
'debian-7-x32':{
100+
'ami':'ami-1be06c6c',
101+
'user':'admin',
102+
'size':'t1.micro'
103+
},
104+
'debian-4-x32':{
105+
'ami':'ami-8198b3f5',
106+
'user':'root',
107+
'size':'m1.small'
108+
},
109+
'ubuntu-12-04-x64':{
110+
'ami':'ami-d1767bb7',
111+
'user':'ubuntu',
112+
'size':'m1.small',
113+
'xlsize':'m3.xlarge',
114+
},
115+
'debian-6-x32':{
116+
'ami':'ami-8d9e4ffa',
117+
'user':'admin',
118+
'size':'t1.micro'
119+
},
120+
'ubuntu-16-04-x64':{
121+
'ami':'ami-0d47c52ffe8fef155',
122+
'user':'ubuntu',
123+
'size':'m1.small',
124+
'xlsize':'m3.xlarge',
125+
},
126+
'debian-5-x64':{
127+
'ami':'ami-8f98b3fb',
128+
'user':'root',
129+
'size':'m1.small'
130+
},
131+
'debian-4-x64':{
132+
'ami':'ami-8d98b3f9',
133+
'user':'root',
134+
'size':'m1.small'
135+
},
136+
'ubuntu-14-04-x64':{
137+
'ami':'ami-0c68b4b8bbbdc39de',
138+
'user':'ubuntu',
139+
'size':'m1.small',
140+
'xlsize':'m3.xlarge',
141+
},
142+
'ubuntu-12-04-x32':{
143+
'ami':'ami-5c78753a',
144+
'user':'ubuntu',
145+
'size':'m1.small'
146+
},
147+
'centos-5-x64':{
148+
'ami':'ami-f2113986',
149+
'user':'root',
150+
'size':'m1.small'
151+
},
152+
'windows-2012-x64':{
153+
'ami':'ami-042fc05480fa9e135',
154+
'user':'Administrator',
155+
'size':'m1.small',
156+
'xlsize':'m3.xlarge',
157+
},
158+
'windows-2016-x64':{
159+
'ami':'ami-0f80e4d47a281dc90',
160+
'user':'Administrator',
161+
'size':'m1.small',
162+
'xlsize':'m3.xlarge',
163+
},
164+
'windows-2019-x64':{
165+
'ami':'ami-07bd93e5f09193501',
166+
'user':'Administrator',
167+
'size':'t2.small',
168+
'xlsize':'t2.xlarge',
169+
},
170+
}

0 commit comments

Comments
 (0)