fastcloudinit 0.0.1__py3-none-any.whl → 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastcloudinit/__init__.py +1 -1
- fastcloudinit/_modidx.py +2 -0
- fastcloudinit/core.py +34 -18
- {fastcloudinit-0.0.1.dist-info → fastcloudinit-0.0.3.dist-info}/METADATA +1 -1
- fastcloudinit-0.0.3.dist-info/RECORD +9 -0
- fastcloudinit-0.0.1.dist-info/RECORD +0 -9
- {fastcloudinit-0.0.1.dist-info → fastcloudinit-0.0.3.dist-info}/WHEEL +0 -0
- {fastcloudinit-0.0.1.dist-info → fastcloudinit-0.0.3.dist-info}/entry_points.txt +0 -0
- {fastcloudinit-0.0.1.dist-info → fastcloudinit-0.0.3.dist-info}/licenses/LICENSE +0 -0
- {fastcloudinit-0.0.1.dist-info → fastcloudinit-0.0.3.dist-info}/top_level.txt +0 -0
fastcloudinit/__init__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "0.0.
|
1
|
+
__version__ = "0.0.3"
|
2
2
|
from .core import *
|
fastcloudinit/_modidx.py
CHANGED
@@ -6,11 +6,13 @@ d = { 'settings': { 'branch': 'main',
|
|
6
6
|
'git_url': 'https://github.com/AnswerDotAI/fastcloudinit',
|
7
7
|
'lib_path': 'fastcloudinit'},
|
8
8
|
'syms': { 'fastcloudinit.core': { 'fastcloudinit.core.apt': ('core.html#apt', 'fastcloudinit/core.py'),
|
9
|
+
'fastcloudinit.core.cloud_init_base': ('core.html#cloud_init_base', 'fastcloudinit/core.py'),
|
9
10
|
'fastcloudinit.core.cloud_init_config': ('core.html#cloud_init_config', 'fastcloudinit/core.py'),
|
10
11
|
'fastcloudinit.core.log_rotate': ('core.html#log_rotate', 'fastcloudinit/core.py'),
|
11
12
|
'fastcloudinit.core.mounts': ('core.html#mounts', 'fastcloudinit/core.py'),
|
12
13
|
'fastcloudinit.core.phone_home': ('core.html#phone_home', 'fastcloudinit/core.py'),
|
13
14
|
'fastcloudinit.core.reboot': ('core.html#reboot', 'fastcloudinit/core.py'),
|
15
|
+
'fastcloudinit.core.runcmd': ('core.html#runcmd', 'fastcloudinit/core.py'),
|
14
16
|
'fastcloudinit.core.source': ('core.html#source', 'fastcloudinit/core.py'),
|
15
17
|
'fastcloudinit.core.systemd': ('core.html#systemd', 'fastcloudinit/core.py'),
|
16
18
|
'fastcloudinit.core.ufw': ('core.html#ufw', 'fastcloudinit/core.py'),
|
fastcloudinit/core.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
2
2
|
|
3
3
|
# %% auto 0
|
4
|
-
__all__ = ['ufw', 'user', 'source', 'apt', 'systemd', 'log_rotate', 'phone_home', 'reboot', 'mounts', '
|
4
|
+
__all__ = ['ufw', 'user', 'source', 'apt', 'systemd', 'log_rotate', 'phone_home', 'reboot', 'mounts', 'runcmd', 'cloud_init_base',
|
5
|
+
'cloud_init_config']
|
5
6
|
|
6
7
|
# %% ../nbs/00_core.ipynb
|
7
8
|
from fastcore.utils import *
|
@@ -10,18 +11,18 @@ from textwrap import dedent
|
|
10
11
|
|
11
12
|
# %% ../nbs/00_core.ipynb
|
12
13
|
def ufw(logging="off", def_incoming="deny", def_outgoing="allow", internal=None, **allows):
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
return
|
14
|
+
cmds = [ f"ufw default {def_incoming} incoming", f"ufw default {def_outgoing} outgoing", f"ufw logging {logging}" ]
|
15
|
+
for name, port in allows.items(): cmds.append("ufw allow {}/tcp".format(port))
|
16
|
+
if internal: cmds.append("ufw allow in on {}".format(internal))
|
17
|
+
cmds.append("ufw --force enable")
|
18
|
+
return cmds
|
18
19
|
|
19
20
|
# %% ../nbs/00_core.ipynb
|
20
|
-
def user(name,
|
21
|
+
def user(name, pub_keys, groups=None, shell="/bin/bash", sudo=True):
|
21
22
|
groups = listify(groups)
|
22
23
|
if sudo and 'sudo' not in groups: groups.append('sudo')
|
23
24
|
sudo = ["ALL=(ALL) NOPASSWD:ALL"] if sudo else []
|
24
|
-
return dict(name=name, groups=groups, shell=shell, sudo=sudo, ssh_authorized_keys=
|
25
|
+
return dict(name=name, groups=groups, shell=shell, sudo=sudo, ssh_authorized_keys=listify(pub_keys))
|
25
26
|
|
26
27
|
# %% ../nbs/00_core.ipynb
|
27
28
|
def source(url, keyid, keyserver):
|
@@ -45,8 +46,11 @@ Unattended-Upgrade::Automatic-Reboot "{auto_reboot}";
|
|
45
46
|
|
46
47
|
# %% ../nbs/00_core.ipynb
|
47
48
|
def systemd(items):
|
48
|
-
|
49
|
-
|
49
|
+
return [
|
50
|
+
{'path': f"/etc/systemd/system/{unit_name}.d/override.conf",
|
51
|
+
'owner': 'root:root', 'permissions': '0644', 'content': content}
|
52
|
+
for unit_name, content in items.items()
|
53
|
+
]
|
50
54
|
|
51
55
|
# %% ../nbs/00_core.ipynb
|
52
56
|
def log_rotate(freq="weekly", num_keep=7, fname="00-cloud-init-global"):
|
@@ -79,19 +83,31 @@ def mounts(devices):
|
|
79
83
|
return dict(mounts=devices)
|
80
84
|
|
81
85
|
# %% ../nbs/00_core.ipynb
|
82
|
-
def
|
83
|
-
|
86
|
+
def runcmd(cmds):
|
87
|
+
if not cmds: return {}
|
88
|
+
return dict(runcmd=cmds)
|
89
|
+
|
90
|
+
# %% ../nbs/00_core.ipynb
|
91
|
+
def cloud_init_base(hostname, packages=None, **kw):
|
84
92
|
cfg = dict(
|
85
93
|
hostname=hostname, preserve_hostname=False,
|
86
|
-
users=[user(username, ssh_pub_key, groups="docker")],
|
87
94
|
packages=listify(packages), package_update=True, package_upgrade=True,
|
88
|
-
disable_root=True, ssh_pwauth=False,
|
89
|
-
|
95
|
+
disable_root=True, ssh_pwauth=False, **kw
|
96
|
+
)
|
97
|
+
return "#cloud-config\n" + yaml.safe_dump(cfg, sort_keys=False, width=1_000_000)
|
98
|
+
|
99
|
+
# %% ../nbs/00_core.ipynb
|
100
|
+
def cloud_init_config(hostname, username, pub_keys, email='', groups=None, internal=None, cmds=None,
|
101
|
+
devices=None, ping_host=None, packages=None, dropins=None, **sources):
|
102
|
+
cmds = listify(cmds)
|
103
|
+
cmds += ufw(internal=internal, OpenSSH=22)
|
104
|
+
return cloud_init_base(
|
105
|
+
hostname, packages=packages,
|
106
|
+
users=[user(username, pub_keys, groups=groups)],
|
107
|
+
**runcmd(cmds),
|
90
108
|
**apt(**sources),
|
91
|
-
|
92
|
-
write_files=[ log_rotate() ],
|
109
|
+
write_files=[ log_rotate(), *systemd(dropins or {}) ],
|
93
110
|
**mounts(devices),
|
94
111
|
**phone_home(ping_host),
|
95
112
|
**reboot(),
|
96
113
|
)
|
97
|
-
return "#cloud-config\n" + yaml.safe_dump(cfg, sort_keys=False, width=1_000_000)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
fastcloudinit/__init__.py,sha256=DyjzzgRJvp3QnEDlrwpSgOvDRy9Thxh14LVq-rV7GgI,42
|
2
|
+
fastcloudinit/_modidx.py,sha256=Wfejm8MTpUUfUqzwtaLDYWPjqaQu81Bi_FdTMW0Heu4,1683
|
3
|
+
fastcloudinit/core.py,sha256=fff9PYHv8u1D7UvtDavEXODi_nICf909BccsIZ20R8U,4097
|
4
|
+
fastcloudinit-0.0.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
5
|
+
fastcloudinit-0.0.3.dist-info/METADATA,sha256=UUgBqHar4bFvZbTraYrExVQ2HuYrwLzgpfE77kVCLVU,1441
|
6
|
+
fastcloudinit-0.0.3.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
7
|
+
fastcloudinit-0.0.3.dist-info/entry_points.txt,sha256=VM6Nnsreaik0SzaZUuuwlWvlBKXIt35OXaFWekbNNY8,48
|
8
|
+
fastcloudinit-0.0.3.dist-info/top_level.txt,sha256=hVbcvprAQ-MXDFdjn5FkVecIwHYPMUikFR7aRiVHkt4,14
|
9
|
+
fastcloudinit-0.0.3.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
fastcloudinit/__init__.py,sha256=XoppFCWM_8XsGAbynKKKg7C3Mca0Kzf_ueJ_7U-l9SE,42
|
2
|
-
fastcloudinit/_modidx.py,sha256=SIjb3ukADOIEBqTQq2etF_24_9Ntm-SejvJgpMD7Fw0,1441
|
3
|
-
fastcloudinit/core.py,sha256=6K4EBWiSZ5SOMcvPjQux6GIacIXmA-Tyvleb02IhBeU,3663
|
4
|
-
fastcloudinit-0.0.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
5
|
-
fastcloudinit-0.0.1.dist-info/METADATA,sha256=TVZrKjwG-6uicLfJ9iyp-cYaqNoIsixT2H8VcYHYdVs,1441
|
6
|
-
fastcloudinit-0.0.1.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
7
|
-
fastcloudinit-0.0.1.dist-info/entry_points.txt,sha256=VM6Nnsreaik0SzaZUuuwlWvlBKXIt35OXaFWekbNNY8,48
|
8
|
-
fastcloudinit-0.0.1.dist-info/top_level.txt,sha256=hVbcvprAQ-MXDFdjn5FkVecIwHYPMUikFR7aRiVHkt4,14
|
9
|
-
fastcloudinit-0.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|