fastcloudinit 0.0.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcloudinit
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: Simplified opinionated cloud init for ubuntu
5
5
  Home-page: https://github.com/AnswerDotAI/fastcloudinit
6
6
  Author: Jeremy Howard
@@ -0,0 +1,2 @@
1
+ __version__ = "0.0.3"
2
+ from .core import *
@@ -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'),
@@ -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', 'cloud_init_config']
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
- rules = [dict(name=k, rule="allow", port=v) for k,v in allows.items()]
14
- if internal: rules.append(dict(interface=internal, rule="allow", direction="in"))
15
- defaults=dict(incoming=def_incoming, outgoing=def_outgoing)
16
- res = dict(enabled=True, logging=logging, defaults=defaults, rules=rules)
17
- return dict(ufw=res)
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, pub_key, groups=None, shell="/bin/bash", sudo=True):
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=[pub_key])
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
- units = [dict(name=k, dropin=True, content=v) for k,v in items.items()]
49
- return dict(systemd=dict(units=units))
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 cloud_init_config(hostname, username, ssh_pub_key, email='',
83
- devices=None, ping_host=None, packages=None, **sources):
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
- **ufw(internal="enp7s0", OpenSSH=22),
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
- **systemd({"systemd-journald.service":"[Journal]\nSystemMaxUse=250M\n"}),
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcloudinit
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: Simplified opinionated cloud init for ubuntu
5
5
  Home-page: https://github.com/AnswerDotAI/fastcloudinit
6
6
  Author: Jeremy Howard
@@ -1,16 +1,10 @@
1
1
  [DEFAULT]
2
- # All sections below are required unless otherwise specified.
3
- # See https://github.com/AnswerDotAI/nbdev/blob/main/settings.ini for examples.
4
-
5
- ### Python library ###
6
2
  repo = fastcloudinit
7
- lib_name = %(repo)s
8
- version = 0.0.1
3
+ lib_name = fastcloudinit
4
+ version = 0.0.3
9
5
  min_python = 3.9
10
6
  license = apache2
11
7
  black_formatting = False
12
-
13
- ### nbdev ###
14
8
  doc_path = _docs
15
9
  lib_path = fastcloudinit
16
10
  nbs_path = nbs
@@ -19,29 +13,27 @@ tst_flags = notest
19
13
  put_version_in_init = True
20
14
  update_pyproject = True
21
15
  cell_number = False
22
-
23
- ### Docs ###
24
16
  branch = main
25
17
  custom_sidebar = False
26
- doc_host = https://%(user)s.github.io
27
- doc_baseurl = /%(repo)s
28
- git_url = https://github.com/%(user)s/%(repo)s
29
- title = %(lib_name)s
30
-
31
- ### PyPI ###
18
+ doc_host = https://AnswerDotAI.github.io
19
+ doc_baseurl = /fastcloudinit
20
+ git_url = https://github.com/AnswerDotAI/fastcloudinit
21
+ title = fastcloudinit
32
22
  audience = Developers
33
23
  author = Jeremy Howard
34
24
  author_email = github@jhoward.fastmail.fm
35
- copyright = 2025 onwards, %(author)s
25
+ copyright = 2025 onwards, Jeremy Howard
36
26
  description = Simplified opinionated cloud init for ubuntu
37
27
  keywords = nbdev jupyter notebook python
38
28
  language = English
39
29
  status = 3
40
30
  user = AnswerDotAI
41
31
  requirements = fastcore PyYAML
32
+ readme_nb = index.ipynb
33
+ allowed_metadata_keys =
34
+ allowed_cell_metadata_keys =
35
+ jupyter_hooks = False
36
+ clean_ids = True
37
+ clear_all = False
38
+ skip_procs =
42
39
 
43
- ### Optional ###
44
- # dev_requirements =
45
- # console_scripts =
46
- # conda_user =
47
- # package_data =
@@ -1,2 +0,0 @@
1
- __version__ = "0.0.1"
2
- from .core import *
File without changes
File without changes
File without changes
File without changes
File without changes