fastcloudinit 0.0.2__tar.gz → 0.0.3__tar.gz
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-0.0.2/fastcloudinit.egg-info → fastcloudinit-0.0.3}/PKG-INFO +1 -1
- fastcloudinit-0.0.3/fastcloudinit/__init__.py +2 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/fastcloudinit/_modidx.py +1 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/fastcloudinit/core.py +20 -30
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3/fastcloudinit.egg-info}/PKG-INFO +1 -1
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/settings.ini +1 -1
- fastcloudinit-0.0.2/fastcloudinit/__init__.py +0 -2
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/LICENSE +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/MANIFEST.in +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/README.md +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/fastcloudinit.egg-info/SOURCES.txt +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/fastcloudinit.egg-info/dependency_links.txt +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/fastcloudinit.egg-info/entry_points.txt +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/fastcloudinit.egg-info/not-zip-safe +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/fastcloudinit.egg-info/requires.txt +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/fastcloudinit.egg-info/top_level.txt +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/pyproject.toml +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/setup.cfg +0 -0
- {fastcloudinit-0.0.2 → fastcloudinit-0.0.3}/setup.py +0 -0
@@ -12,6 +12,7 @@ d = { 'settings': { 'branch': 'main',
|
|
12
12
|
'fastcloudinit.core.mounts': ('core.html#mounts', 'fastcloudinit/core.py'),
|
13
13
|
'fastcloudinit.core.phone_home': ('core.html#phone_home', 'fastcloudinit/core.py'),
|
14
14
|
'fastcloudinit.core.reboot': ('core.html#reboot', 'fastcloudinit/core.py'),
|
15
|
+
'fastcloudinit.core.runcmd': ('core.html#runcmd', 'fastcloudinit/core.py'),
|
15
16
|
'fastcloudinit.core.source': ('core.html#source', 'fastcloudinit/core.py'),
|
16
17
|
'fastcloudinit.core.systemd': ('core.html#systemd', 'fastcloudinit/core.py'),
|
17
18
|
'fastcloudinit.core.ufw': ('core.html#ufw', 'fastcloudinit/core.py'),
|
@@ -1,8 +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', '
|
5
|
-
'
|
4
|
+
__all__ = ['ufw', 'user', 'source', 'apt', 'systemd', 'log_rotate', 'phone_home', 'reboot', 'mounts', 'runcmd', 'cloud_init_base',
|
5
|
+
'cloud_init_config']
|
6
6
|
|
7
7
|
# %% ../nbs/00_core.ipynb
|
8
8
|
from fastcore.utils import *
|
@@ -11,11 +11,11 @@ from textwrap import dedent
|
|
11
11
|
|
12
12
|
# %% ../nbs/00_core.ipynb
|
13
13
|
def ufw(logging="off", def_incoming="deny", def_outgoing="allow", internal=None, **allows):
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
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
|
19
19
|
|
20
20
|
# %% ../nbs/00_core.ipynb
|
21
21
|
def user(name, pub_keys, groups=None, shell="/bin/bash", sudo=True):
|
@@ -46,8 +46,11 @@ Unattended-Upgrade::Automatic-Reboot "{auto_reboot}";
|
|
46
46
|
|
47
47
|
# %% ../nbs/00_core.ipynb
|
48
48
|
def systemd(items):
|
49
|
-
|
50
|
-
|
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
|
+
]
|
51
54
|
|
52
55
|
# %% ../nbs/00_core.ipynb
|
53
56
|
def log_rotate(freq="weekly", num_keep=7, fname="00-cloud-init-global"):
|
@@ -80,23 +83,9 @@ def mounts(devices):
|
|
80
83
|
return dict(mounts=devices)
|
81
84
|
|
82
85
|
# %% ../nbs/00_core.ipynb
|
83
|
-
def
|
84
|
-
|
85
|
-
|
86
|
-
cfg = dict(
|
87
|
-
hostname=hostname, preserve_hostname=False,
|
88
|
-
users=[user(username, pub_keys, groups="docker")],
|
89
|
-
packages=listify(packages), package_update=True, package_upgrade=True,
|
90
|
-
disable_root=True, ssh_pwauth=False,
|
91
|
-
**ufw(internal="enp7s0", OpenSSH=22),
|
92
|
-
**apt(**sources),
|
93
|
-
**systemd(dropins),
|
94
|
-
write_files=[ log_rotate() ],
|
95
|
-
**mounts(devices),
|
96
|
-
**phone_home(ping_host),
|
97
|
-
**reboot(),
|
98
|
-
)
|
99
|
-
return "#cloud-config\n" + yaml.safe_dump(cfg, sort_keys=False, width=1_000_000)
|
86
|
+
def runcmd(cmds):
|
87
|
+
if not cmds: return {}
|
88
|
+
return dict(runcmd=cmds)
|
100
89
|
|
101
90
|
# %% ../nbs/00_core.ipynb
|
102
91
|
def cloud_init_base(hostname, packages=None, **kw):
|
@@ -108,15 +97,16 @@ def cloud_init_base(hostname, packages=None, **kw):
|
|
108
97
|
return "#cloud-config\n" + yaml.safe_dump(cfg, sort_keys=False, width=1_000_000)
|
109
98
|
|
110
99
|
# %% ../nbs/00_core.ipynb
|
111
|
-
def cloud_init_config(hostname, username, pub_keys, email='', groups=None, internal=None,
|
100
|
+
def cloud_init_config(hostname, username, pub_keys, email='', groups=None, internal=None, cmds=None,
|
112
101
|
devices=None, ping_host=None, packages=None, dropins=None, **sources):
|
102
|
+
cmds = listify(cmds)
|
103
|
+
cmds += ufw(internal=internal, OpenSSH=22)
|
113
104
|
return cloud_init_base(
|
114
105
|
hostname, packages=packages,
|
115
106
|
users=[user(username, pub_keys, groups=groups)],
|
116
|
-
**
|
107
|
+
**runcmd(cmds),
|
117
108
|
**apt(**sources),
|
118
|
-
|
119
|
-
write_files=[ log_rotate() ],
|
109
|
+
write_files=[ log_rotate(), *systemd(dropins or {}) ],
|
120
110
|
**mounts(devices),
|
121
111
|
**phone_home(ping_host),
|
122
112
|
**reboot(),
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|