pyinfra 0.11.dev3__py3-none-any.whl → 3.5.1__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.
Files changed (203) hide show
  1. pyinfra/__init__.py +9 -12
  2. pyinfra/__main__.py +4 -0
  3. pyinfra/api/__init__.py +18 -3
  4. pyinfra/api/arguments.py +406 -0
  5. pyinfra/api/arguments_typed.py +79 -0
  6. pyinfra/api/command.py +274 -0
  7. pyinfra/api/config.py +222 -28
  8. pyinfra/api/connect.py +33 -13
  9. pyinfra/api/connectors.py +27 -0
  10. pyinfra/api/deploy.py +65 -66
  11. pyinfra/api/exceptions.py +67 -18
  12. pyinfra/api/facts.py +253 -202
  13. pyinfra/api/host.py +413 -50
  14. pyinfra/api/inventory.py +121 -160
  15. pyinfra/api/operation.py +432 -262
  16. pyinfra/api/operations.py +273 -260
  17. pyinfra/api/state.py +302 -248
  18. pyinfra/api/util.py +291 -368
  19. pyinfra/connectors/base.py +173 -0
  20. pyinfra/connectors/chroot.py +212 -0
  21. pyinfra/connectors/docker.py +381 -0
  22. pyinfra/connectors/dockerssh.py +297 -0
  23. pyinfra/connectors/local.py +238 -0
  24. pyinfra/connectors/scp/__init__.py +1 -0
  25. pyinfra/connectors/scp/client.py +204 -0
  26. pyinfra/connectors/ssh.py +670 -0
  27. pyinfra/connectors/ssh_util.py +114 -0
  28. pyinfra/connectors/sshuserclient/client.py +309 -0
  29. pyinfra/connectors/sshuserclient/config.py +102 -0
  30. pyinfra/connectors/terraform.py +135 -0
  31. pyinfra/connectors/util.py +410 -0
  32. pyinfra/connectors/vagrant.py +183 -0
  33. pyinfra/context.py +145 -0
  34. pyinfra/facts/__init__.py +7 -6
  35. pyinfra/facts/apk.py +22 -7
  36. pyinfra/facts/apt.py +117 -60
  37. pyinfra/facts/brew.py +100 -15
  38. pyinfra/facts/bsdinit.py +23 -0
  39. pyinfra/facts/cargo.py +37 -0
  40. pyinfra/facts/choco.py +47 -0
  41. pyinfra/facts/crontab.py +195 -0
  42. pyinfra/facts/deb.py +94 -0
  43. pyinfra/facts/dnf.py +48 -0
  44. pyinfra/facts/docker.py +96 -23
  45. pyinfra/facts/efibootmgr.py +113 -0
  46. pyinfra/facts/files.py +630 -58
  47. pyinfra/facts/flatpak.py +77 -0
  48. pyinfra/facts/freebsd.py +70 -0
  49. pyinfra/facts/gem.py +19 -6
  50. pyinfra/facts/git.py +59 -14
  51. pyinfra/facts/gpg.py +150 -0
  52. pyinfra/facts/hardware.py +313 -167
  53. pyinfra/facts/iptables.py +72 -62
  54. pyinfra/facts/launchd.py +44 -0
  55. pyinfra/facts/lxd.py +17 -4
  56. pyinfra/facts/mysql.py +122 -86
  57. pyinfra/facts/npm.py +17 -9
  58. pyinfra/facts/openrc.py +71 -0
  59. pyinfra/facts/opkg.py +246 -0
  60. pyinfra/facts/pacman.py +50 -7
  61. pyinfra/facts/pip.py +24 -7
  62. pyinfra/facts/pipx.py +82 -0
  63. pyinfra/facts/pkg.py +15 -6
  64. pyinfra/facts/pkgin.py +35 -0
  65. pyinfra/facts/podman.py +54 -0
  66. pyinfra/facts/postgres.py +178 -0
  67. pyinfra/facts/postgresql.py +6 -147
  68. pyinfra/facts/rpm.py +105 -0
  69. pyinfra/facts/runit.py +77 -0
  70. pyinfra/facts/selinux.py +161 -0
  71. pyinfra/facts/server.py +746 -285
  72. pyinfra/facts/snap.py +88 -0
  73. pyinfra/facts/systemd.py +139 -0
  74. pyinfra/facts/sysvinit.py +59 -0
  75. pyinfra/facts/upstart.py +35 -0
  76. pyinfra/facts/util/__init__.py +17 -0
  77. pyinfra/facts/util/databases.py +4 -6
  78. pyinfra/facts/util/packaging.py +37 -6
  79. pyinfra/facts/util/units.py +30 -0
  80. pyinfra/facts/util/win_files.py +99 -0
  81. pyinfra/facts/vzctl.py +20 -13
  82. pyinfra/facts/xbps.py +35 -0
  83. pyinfra/facts/yum.py +34 -40
  84. pyinfra/facts/zfs.py +77 -0
  85. pyinfra/facts/zypper.py +42 -0
  86. pyinfra/local.py +45 -83
  87. pyinfra/operations/__init__.py +12 -0
  88. pyinfra/operations/apk.py +98 -0
  89. pyinfra/operations/apt.py +488 -0
  90. pyinfra/operations/brew.py +231 -0
  91. pyinfra/operations/bsdinit.py +59 -0
  92. pyinfra/operations/cargo.py +45 -0
  93. pyinfra/operations/choco.py +61 -0
  94. pyinfra/operations/crontab.py +191 -0
  95. pyinfra/operations/dnf.py +210 -0
  96. pyinfra/operations/docker.py +446 -0
  97. pyinfra/operations/files.py +1939 -0
  98. pyinfra/operations/flatpak.py +94 -0
  99. pyinfra/operations/freebsd/__init__.py +12 -0
  100. pyinfra/operations/freebsd/freebsd_update.py +70 -0
  101. pyinfra/operations/freebsd/pkg.py +219 -0
  102. pyinfra/operations/freebsd/service.py +116 -0
  103. pyinfra/operations/freebsd/sysrc.py +92 -0
  104. pyinfra/operations/gem.py +47 -0
  105. pyinfra/operations/git.py +419 -0
  106. pyinfra/operations/iptables.py +311 -0
  107. pyinfra/operations/launchd.py +45 -0
  108. pyinfra/operations/lxd.py +68 -0
  109. pyinfra/operations/mysql.py +609 -0
  110. pyinfra/operations/npm.py +57 -0
  111. pyinfra/operations/openrc.py +63 -0
  112. pyinfra/operations/opkg.py +88 -0
  113. pyinfra/operations/pacman.py +81 -0
  114. pyinfra/operations/pip.py +205 -0
  115. pyinfra/operations/pipx.py +102 -0
  116. pyinfra/operations/pkg.py +70 -0
  117. pyinfra/operations/pkgin.py +91 -0
  118. pyinfra/operations/postgres.py +436 -0
  119. pyinfra/operations/postgresql.py +30 -0
  120. pyinfra/operations/puppet.py +40 -0
  121. pyinfra/operations/python.py +72 -0
  122. pyinfra/operations/runit.py +184 -0
  123. pyinfra/operations/selinux.py +189 -0
  124. pyinfra/operations/server.py +1099 -0
  125. pyinfra/operations/snap.py +117 -0
  126. pyinfra/operations/ssh.py +216 -0
  127. pyinfra/operations/systemd.py +149 -0
  128. pyinfra/operations/sysvinit.py +141 -0
  129. pyinfra/operations/upstart.py +68 -0
  130. pyinfra/operations/util/__init__.py +12 -0
  131. pyinfra/operations/util/docker.py +251 -0
  132. pyinfra/operations/util/files.py +247 -0
  133. pyinfra/operations/util/packaging.py +336 -0
  134. pyinfra/operations/util/service.py +46 -0
  135. pyinfra/operations/vzctl.py +137 -0
  136. pyinfra/operations/xbps.py +77 -0
  137. pyinfra/operations/yum.py +210 -0
  138. pyinfra/operations/zfs.py +175 -0
  139. pyinfra/operations/zypper.py +192 -0
  140. pyinfra/progress.py +44 -32
  141. pyinfra/py.typed +0 -0
  142. pyinfra/version.py +9 -1
  143. pyinfra-3.5.1.dist-info/METADATA +141 -0
  144. pyinfra-3.5.1.dist-info/RECORD +159 -0
  145. {pyinfra-0.11.dev3.dist-info → pyinfra-3.5.1.dist-info}/WHEEL +1 -2
  146. pyinfra-3.5.1.dist-info/entry_points.txt +12 -0
  147. {pyinfra-0.11.dev3.dist-info → pyinfra-3.5.1.dist-info/licenses}/LICENSE.md +1 -1
  148. pyinfra_cli/__init__.py +1 -0
  149. pyinfra_cli/cli.py +780 -0
  150. pyinfra_cli/commands.py +66 -0
  151. pyinfra_cli/exceptions.py +155 -65
  152. pyinfra_cli/inventory.py +233 -89
  153. pyinfra_cli/log.py +39 -43
  154. pyinfra_cli/main.py +26 -495
  155. pyinfra_cli/prints.py +215 -156
  156. pyinfra_cli/util.py +172 -105
  157. pyinfra_cli/virtualenv.py +25 -20
  158. pyinfra/api/connectors/__init__.py +0 -21
  159. pyinfra/api/connectors/ansible.py +0 -99
  160. pyinfra/api/connectors/docker.py +0 -178
  161. pyinfra/api/connectors/local.py +0 -169
  162. pyinfra/api/connectors/ssh.py +0 -402
  163. pyinfra/api/connectors/sshuserclient/client.py +0 -105
  164. pyinfra/api/connectors/sshuserclient/config.py +0 -90
  165. pyinfra/api/connectors/util.py +0 -63
  166. pyinfra/api/connectors/vagrant.py +0 -155
  167. pyinfra/facts/init.py +0 -176
  168. pyinfra/facts/util/files.py +0 -102
  169. pyinfra/hook.py +0 -41
  170. pyinfra/modules/__init__.py +0 -11
  171. pyinfra/modules/apk.py +0 -64
  172. pyinfra/modules/apt.py +0 -272
  173. pyinfra/modules/brew.py +0 -122
  174. pyinfra/modules/files.py +0 -711
  175. pyinfra/modules/gem.py +0 -30
  176. pyinfra/modules/git.py +0 -115
  177. pyinfra/modules/init.py +0 -344
  178. pyinfra/modules/iptables.py +0 -271
  179. pyinfra/modules/lxd.py +0 -45
  180. pyinfra/modules/mysql.py +0 -347
  181. pyinfra/modules/npm.py +0 -47
  182. pyinfra/modules/pacman.py +0 -60
  183. pyinfra/modules/pip.py +0 -99
  184. pyinfra/modules/pkg.py +0 -43
  185. pyinfra/modules/postgresql.py +0 -245
  186. pyinfra/modules/puppet.py +0 -20
  187. pyinfra/modules/python.py +0 -37
  188. pyinfra/modules/server.py +0 -524
  189. pyinfra/modules/ssh.py +0 -150
  190. pyinfra/modules/util/files.py +0 -52
  191. pyinfra/modules/util/packaging.py +0 -118
  192. pyinfra/modules/vzctl.py +0 -133
  193. pyinfra/modules/yum.py +0 -171
  194. pyinfra/pseudo_modules.py +0 -64
  195. pyinfra-0.11.dev3.dist-info/.DS_Store +0 -0
  196. pyinfra-0.11.dev3.dist-info/METADATA +0 -135
  197. pyinfra-0.11.dev3.dist-info/RECORD +0 -95
  198. pyinfra-0.11.dev3.dist-info/entry_points.txt +0 -3
  199. pyinfra-0.11.dev3.dist-info/top_level.txt +0 -2
  200. pyinfra_cli/__main__.py +0 -40
  201. pyinfra_cli/config.py +0 -92
  202. /pyinfra/{modules/util → connectors}/__init__.py +0 -0
  203. /pyinfra/{api/connectors → connectors}/sshuserclient/__init__.py +0 -0
pyinfra/modules/pacman.py DELETED
@@ -1,60 +0,0 @@
1
- '''
2
- Mange pacman packages.
3
- '''
4
-
5
- from pyinfra.api import operation
6
-
7
- from .util.packaging import ensure_packages
8
-
9
-
10
- @operation
11
- def upgrade(state, host):
12
- '''
13
- Upgrades all pacman packages.
14
- '''
15
-
16
- yield 'pacman --noconfirm -Su'
17
-
18
- _upgrade = upgrade # noqa: E305
19
-
20
-
21
- @operation
22
- def update(state, host):
23
- '''
24
- Updates pacman repositories.
25
- '''
26
-
27
- yield 'pacman -Sy'
28
-
29
- _update = update # noqa: E305
30
-
31
-
32
- @operation
33
- def packages(
34
- state, host,
35
- packages=None, present=True,
36
- update=False, upgrade=False,
37
- ):
38
- '''
39
- Add/remove pacman packages.
40
-
41
- + packages: list of packages to ensure
42
- + present: whether the packages should be installed
43
- + update: run pacman -Sy before installing packages
44
- + upgrade: run pacman -Syu before installing packages
45
-
46
- Versions:
47
- Package versions can be pinned like pacman: ``<pkg>=<version>``.
48
- '''
49
-
50
- if update:
51
- yield _update(state, host)
52
-
53
- if upgrade:
54
- yield _upgrade(state, host)
55
-
56
- yield ensure_packages(
57
- packages, host.fact.pacman_packages, present,
58
- install_command='pacman --noconfirm -S',
59
- uninstall_command='pacman --noconfirm -R',
60
- )
pyinfra/modules/pip.py DELETED
@@ -1,99 +0,0 @@
1
- '''
2
- Manage pip packages. Compatible globally or inside a virtualenv.
3
- '''
4
-
5
- from pyinfra.api import operation
6
- from pyinfra.modules import files
7
-
8
- from .util.packaging import ensure_packages
9
-
10
-
11
- @operation
12
- def virtualenv(
13
- state, host, path,
14
- python=None, site_packages=False, always_copy=False, present=True,
15
- ):
16
- '''
17
- Add/remove Python virtualenvs.
18
-
19
- + python: python interpreter to use
20
- + site_packages: give access to the global site-packages
21
- + always_copy: always copy files rather than symlinking
22
- + present: whether the virtualenv should exist
23
- '''
24
-
25
- if present is False and host.fact.directory(path):
26
- yield files.directory(state, host, path, present=False)
27
-
28
- elif present and not host.fact.directory(path):
29
- # Create missing virtualenv
30
- command = ['virtualenv']
31
-
32
- if python:
33
- command.append('-p {0}'.format(python))
34
-
35
- if site_packages:
36
- command.append('--system-site-packages')
37
-
38
- if always_copy:
39
- command.append('--always-copy')
40
-
41
- command.append(path)
42
-
43
- yield ' '.join(command)
44
-
45
- _virtualenv = virtualenv # noqa
46
-
47
-
48
- @operation
49
- def packages(
50
- state, host,
51
- packages=None, present=True, latest=False,
52
- requirements=None, pip='pip', virtualenv=None, virtualenv_kwargs=None,
53
- ):
54
- '''
55
- Install/remove/update pip packages.
56
-
57
- + packages: list of packages to ensure
58
- + present: whether the packages should be installed
59
- + latest: whether to upgrade packages without a specified version
60
- + requirements: location of requirements file to install
61
- + pip: name or path of the pip directory to use
62
- + virtualenv: root directory of virtualenv to work in
63
- + virtualenv_kwargs: dictionary of arguments to pass to ``pip.virtualenv``
64
-
65
- Virtualenv:
66
- This will be created if it does not exist already. ``virtualenv_kwargs``
67
- will be passed to ``pip.virtualenv`` which can be used to control how
68
- the env is created.
69
-
70
- Versions:
71
- Package versions can be pinned like pip: ``<pkg>==<version>``.
72
- '''
73
-
74
- virtualenv_kwargs = virtualenv_kwargs or {}
75
-
76
- # Ensure any virutalenv
77
- if virtualenv:
78
- yield _virtualenv(state, host, virtualenv, **virtualenv_kwargs)
79
-
80
- # And update pip path
81
- virtualenv = virtualenv.rstrip('/')
82
- pip = '{0}/bin/{1}'.format(virtualenv, pip)
83
-
84
- # Install requirements
85
- if requirements is not None:
86
- yield '{0} install -r {1}'.format(pip, requirements)
87
-
88
- # Handle passed in packages
89
- if packages:
90
- current_packages = host.fact.pip_packages(pip)
91
-
92
- yield ensure_packages(
93
- packages, current_packages, present,
94
- install_command='{0} install'.format(pip),
95
- uninstall_command='{0} uninstall'.format(pip),
96
- upgrade_command='{0} install --upgrade'.format(pip),
97
- version_join='==',
98
- latest=latest,
99
- )
pyinfra/modules/pkg.py DELETED
@@ -1,43 +0,0 @@
1
- '''
2
- Manage BSD packages and repositories. Note that BSD package names are case-sensitive.
3
- '''
4
-
5
- from pyinfra.api import operation
6
-
7
- from .util.packaging import ensure_packages
8
-
9
-
10
- @operation
11
- def packages(state, host, packages=None, present=True, pkg_path=None):
12
- '''
13
- Install/remove/update pkg_* packages.
14
-
15
- + packages: list of packages to ensure
16
- + present: whether the packages should be installed
17
- + pkg_path: the PKG_PATH environment variable to set
18
-
19
- pkg_path:
20
- By default this is autogenerated as follows (tested/working for OpenBSD):
21
- ``http://ftp.<OS>.org/pub/<OS>/<VERSION>/packages/<ARCH>/``. Note that OpenBSD's
22
- official mirrors only hold the latest two versions packages.
23
-
24
- NetBSD/FreeBSD helpfully use their own directory structures, so the default won't
25
- work.
26
- '''
27
-
28
- if present is True:
29
- # Autogenerate package path
30
- if not pkg_path:
31
- host_os = host.fact.os or ''
32
- pkg_path = 'http://ftp.{http}.org/pub/{os}/{version}/packages/{arch}/'.format(
33
- http=host_os.lower(),
34
- os=host_os,
35
- version=host.fact.os_version,
36
- arch=host.fact.arch,
37
- )
38
-
39
- yield ensure_packages(
40
- packages, host.fact.pkg_packages, present,
41
- install_command='PKG_PATH={0} pkg_add'.format(pkg_path),
42
- uninstall_command='pkg_delete',
43
- )
@@ -1,245 +0,0 @@
1
- '''
2
- The PostgreSQL modules manage PostgreSQL databases, users and privileges.
3
-
4
- Requires the ``psql`` CLI executable on the target host(s).
5
-
6
- All operations in this module take four optional global arguments:
7
- + ``postgresql_user``: the username to connect to postgresql to
8
- + ``postgresql_password``: the password for the connecting user
9
- + ``postgresql_host``: the hostname of the server to connect to
10
- + ``postgresql_port``: the port of the server to connect to
11
- '''
12
-
13
- from pyinfra.api import operation
14
- from pyinfra.facts.postgresql import make_execute_psql_command, make_psql_command
15
-
16
-
17
- @operation
18
- def sql(
19
- state, host, sql,
20
- database=None,
21
- # Details for speaking to PostgreSQL via `psql` CLI
22
- postgresql_user=None, postgresql_password=None,
23
- postgresql_host=None, postgresql_port=None,
24
- ):
25
- '''
26
- Execute arbitrary SQL against PostgreSQL.
27
-
28
- + sql: SQL command(s) to execute
29
- + database: optional database to execute against
30
- + postgresql_*: global module arguments, see above
31
- '''
32
-
33
- yield make_execute_psql_command(
34
- sql,
35
- database=database,
36
- user=postgresql_user,
37
- password=postgresql_password,
38
- host=postgresql_host,
39
- port=postgresql_port,
40
- )
41
-
42
-
43
- @operation
44
- def role(
45
- state, host, name,
46
- present=True,
47
- password=None, login=True, superuser=False, inherit=False,
48
- createdb=False, createrole=False, replication=False, connection_limit=None,
49
- # Details for speaking to PostgreSQL via `psql` CLI
50
- postgresql_user=None, postgresql_password=None,
51
- postgresql_host=None, postgresql_port=None,
52
- ):
53
- '''
54
- Add/remove PostgreSQL roles.
55
-
56
- + name: name of the role
57
- + present: whether the role should be present or absent
58
- + password: the password for the role
59
- + login: whether the role can login
60
- + superuser: whether role will be a superuser
61
- + inherit: whether the role inherits from other roles
62
- + createdb: whether the role is allowed to create databases
63
- + createrole: whether the role is allowed to create new roles
64
- + replication: whether this role is allowed to replicate
65
- + connection_limit: the connection limit for the role
66
- + postgresql_*: global module arguments, see above
67
-
68
- Updates:
69
- pyinfra will not attempt to change existing roles - it will either
70
- create or drop roles, but not alter them (if the role exists this
71
- operation will make no changes).
72
- '''
73
-
74
- roles = host.fact.postgresql_roles(
75
- postgresql_user, postgresql_password,
76
- postgresql_host, postgresql_port,
77
- )
78
-
79
- is_present = name in roles
80
-
81
- # User not wanted?
82
- if not present:
83
- if is_present:
84
- yield make_execute_psql_command(
85
- 'DROP ROLE {0}'.format(name),
86
- user=postgresql_user,
87
- password=postgresql_password,
88
- host=postgresql_host,
89
- port=postgresql_port,
90
- )
91
- return
92
-
93
- # If we want the user and they don't exist
94
- if not is_present:
95
- sql_bits = ['CREATE ROLE {0}'.format(name)]
96
-
97
- for key, value in (
98
- ('LOGIN', login),
99
- ('SUPERUSER', superuser),
100
- ('INHERIT', inherit),
101
- ('CREATEDB', createdb),
102
- ('CREATEROLE', createrole),
103
- ('REPLICATION', replication),
104
- ):
105
- if value:
106
- sql_bits.append(key)
107
-
108
- if connection_limit:
109
- sql_bits.append('CONNECTION LIMIT {0}'.format(connection_limit))
110
-
111
- if password:
112
- sql_bits.append("PASSWORD '{0}'".format(password))
113
-
114
- yield make_execute_psql_command(
115
- ' '.join(sql_bits),
116
- user=postgresql_user,
117
- password=postgresql_password,
118
- host=postgresql_host,
119
- port=postgresql_port,
120
- )
121
-
122
-
123
- @operation
124
- def database(
125
- state, host, name,
126
- present=True, owner=None,
127
- template=None, encoding=None,
128
- lc_collate=None, lc_ctype=None, tablespace=None,
129
- connection_limit=None,
130
- # Details for speaking to PostgreSQL via `psql` CLI
131
- postgresql_user=None, postgresql_password=None,
132
- postgresql_host=None, postgresql_port=None,
133
- ):
134
- '''
135
- Add/remove PostgreSQL databases.
136
-
137
- + name: name of the database
138
- + present: whether the database should exist or not
139
- + owner: the PostgreSQL role that owns the database
140
- + template: name of the PostgreSQL template to use
141
- + encoding: encoding of the database
142
- + lc_collate: lc_collate of the database
143
- + lc_ctype: lc_ctype of the database
144
- + tablespace: the tablespace to use for the template
145
- + connection_limit: the connection limit to apply to the database
146
- + postgresql_*: global module arguments, see above
147
-
148
- Updates:
149
- pyinfra will not attempt to change existing databases - it will either
150
- create or drop databases, but not alter them (if the db exists this
151
- operation will make no changes).
152
- '''
153
-
154
- current_databases = host.fact.postgresql_databases(
155
- postgresql_user, postgresql_password,
156
- postgresql_host, postgresql_port,
157
- )
158
-
159
- is_present = name in current_databases
160
-
161
- if not present:
162
- if is_present:
163
- yield make_execute_psql_command(
164
- 'DROP DATABASE {0}'.format(name),
165
- user=postgresql_user,
166
- password=postgresql_password,
167
- host=postgresql_host,
168
- port=postgresql_port,
169
- )
170
- return
171
-
172
- # We want the database but it doesn't exist
173
- if present and not is_present:
174
- sql_bits = ['CREATE DATABASE {0}'.format(name)]
175
-
176
- for key, value in (
177
- ('OWNER', owner),
178
- ('TEMPLATE', template),
179
- ('ENCODING', encoding),
180
- ('LC_COLLATE', lc_collate),
181
- ('LC_CTYPE', lc_ctype),
182
- ('TABLESPACE', tablespace),
183
- ('CONNECTION LIMIT', connection_limit),
184
- ):
185
- if value:
186
- sql_bits.append('{0} {1}'.format(key, value))
187
-
188
- yield make_execute_psql_command(
189
- ' '.join(sql_bits),
190
- user=postgresql_user,
191
- password=postgresql_password,
192
- host=postgresql_host,
193
- port=postgresql_port,
194
- )
195
-
196
-
197
- @operation
198
- def dump(
199
- state, host,
200
- remote_filename, database=None,
201
- # Details for speaking to PostgreSQL via `psql` CLI
202
- postgresql_user=None, postgresql_password=None,
203
- postgresql_host=None, postgresql_port=None,
204
- ):
205
- '''
206
- Dump a PostgreSQL database into a ``.sql`` file. Requires ``mysqldump``.
207
-
208
- + database: name of the database to dump
209
- + remote_filename: name of the file to dump the SQL to
210
- + postgresql_*: global module arguments, see above
211
- '''
212
-
213
- yield '{0} > {1}'.format(make_psql_command(
214
- executable='pg_dump',
215
- database=database,
216
- user=postgresql_user,
217
- password=postgresql_password,
218
- host=postgresql_host,
219
- port=postgresql_port,
220
- ), remote_filename)
221
-
222
-
223
- @operation
224
- def load(
225
- state, host,
226
- remote_filename, database=None,
227
- # Details for speaking to PostgreSQL via `psql` CLI
228
- postgresql_user=None, postgresql_password=None,
229
- postgresql_host=None, postgresql_port=None,
230
- ):
231
- '''
232
- Load ``.sql`` file into a database.
233
-
234
- + database: name of the database to import into
235
- + remote_filename: the filename to read from
236
- + postgresql_*: global module arguments, see above
237
- '''
238
-
239
- yield '{0} < {1}'.format(make_psql_command(
240
- database=database,
241
- user=postgresql_user,
242
- password=postgresql_password,
243
- host=postgresql_host,
244
- port=postgresql_port,
245
- ), remote_filename)
pyinfra/modules/puppet.py DELETED
@@ -1,20 +0,0 @@
1
- from pyinfra.api import operation
2
-
3
-
4
- @operation
5
- def agent(state, host, server=None, port=None):
6
- '''
7
- Run puppet agent
8
-
9
- + server: master server URL
10
- + port: puppet master port
11
- '''
12
-
13
- args = []
14
-
15
- if server:
16
- args.append('--server=%s' % server)
17
- if port:
18
- args.append('--masterport=%s' % port)
19
-
20
- yield 'puppet agent -t %s' % ' '.join(args)
pyinfra/modules/python.py DELETED
@@ -1,37 +0,0 @@
1
- '''
2
- The Python module allows you to execute Python code within the context of a deploy.
3
- '''
4
-
5
- from pyinfra.api import operation
6
-
7
-
8
- @operation
9
- def call(state, host, func, *args, **kwargs):
10
- '''
11
- Execute a Python function within a deploy.
12
-
13
- + func: the function to execute
14
- + args: additional arguments to pass to the function
15
- + kwargs: additional keyword arguments to pass to the function
16
-
17
- Callback functions arge passed the state, host, and any args/kwargs passed
18
- into the operation directly, eg:
19
-
20
- .. code:: python
21
-
22
- def my_callback(state, host, hello=None):
23
- ...
24
-
25
- python.call(my_callback, hello='world')
26
-
27
- '''
28
-
29
- yield (func, args, kwargs)
30
-
31
-
32
- @operation
33
- def raise_exception(state, host, exception_class, *args, **kwargs):
34
- def raise_exc(*args, **kwargs): # pragma: no cover
35
- raise exception_class(*args, **kwargs)
36
-
37
- yield (raise_exc, args, kwargs)