Skip to content

Commit a300d05

Browse files
committed
Expand idempotency flags on operations & operation tests.
1 parent ec24edb commit a300d05

File tree

24 files changed

+51
-33
lines changed

24 files changed

+51
-33
lines changed

pyinfra/operations/apt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def update(cache_time=None, touch_periodic=False, state=None, host=None):
325325
_update = update # noqa: E305
326326

327327

328-
@operation
328+
@operation(is_idempotent=False)
329329
def upgrade(state, host):
330330
'''
331331
Upgrades all apt packages.

pyinfra/operations/mysql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pyinfra.facts.mysql import make_execute_mysql_command, make_mysql_command
2020

2121

22-
@operation
22+
@operation(is_idempotent=False)
2323
def sql(
2424
sql,
2525
database=None,
@@ -511,7 +511,7 @@ def privileges(
511511
_privileges = privileges # noqa: E305 (for use where kwarg is the same)
512512

513513

514-
@operation
514+
@operation(is_idempotent=False)
515515
def dump(
516516
dest, database=None,
517517
# Details for speaking to MySQL via `mysql` CLI
@@ -547,7 +547,7 @@ def dump(
547547
), dest)
548548

549549

550-
@operation
550+
@operation(is_idempotent=False)
551551
def load(
552552
src, database=None,
553553
# Details for speaking to MySQL via `mysql` CLI

pyinfra/operations/postgresql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from pyinfra.facts.postgresql import make_execute_psql_command, make_psql_command
1818

1919

20-
@operation
20+
@operation(is_idempotent=False)
2121
def sql(
2222
sql,
2323
database=None,
@@ -235,7 +235,7 @@ def database(
235235
host.noop('postgresql database {0} exists'.format(database))
236236

237237

238-
@operation
238+
@operation(is_idempotent=False)
239239
def dump(
240240
dest, database=None,
241241
# Details for speaking to PostgreSQL via `psql` CLI
@@ -273,7 +273,7 @@ def dump(
273273
), '>', dest)
274274

275275

276-
@operation
276+
@operation(is_idempotent=False)
277277
def load(
278278
src, database=None,
279279
# Details for speaking to PostgreSQL via `psql` CLI

pyinfra/operations/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from .util.files import chmod, sed_replace
5050

5151

52-
@operation
52+
@operation(is_idempotent=False)
5353
def reboot(delay=10, interval=1, reboot_timeout=300, state=None, host=None):
5454
'''
5555
Reboot the server and wait for reconnection.
@@ -102,7 +102,7 @@ def wait_and_reconnect(state, host): # pragma: no cover
102102
yield FunctionCommand(wait_and_reconnect, (), {})
103103

104104

105-
@operation
105+
@operation(is_idempotent=False)
106106
def wait(port=None, state=None, host=None):
107107
'''
108108
Waits for a port to come active on the target machine. Requires netstat, checks every
@@ -128,7 +128,7 @@ def wait(port=None, state=None, host=None):
128128
'''.format(port)
129129

130130

131-
@operation
131+
@operation(is_idempotent=False)
132132
def shell(commands, state=None, host=None):
133133
'''
134134
Run raw shell code on server during a deploy. If the command would
@@ -155,7 +155,7 @@ def shell(commands, state=None, host=None):
155155
yield command
156156

157157

158-
@operation
158+
@operation(is_idempotent=False)
159159
def script(src, state=None, host=None):
160160
'''
161161
Upload and execute a local script on the remote host.
@@ -180,7 +180,7 @@ def script(src, state=None, host=None):
180180
yield temp_file
181181

182182

183-
@operation
183+
@operation(is_idempotent=False)
184184
def script_template(src, state=None, host=None, **data):
185185
'''
186186
Generate, upload and execute a local script template on the remote host.

pyinfra/operations/ssh.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _user_or_ssh_user(user, ssh_user):
6868
return user or ssh_user
6969

7070

71-
@operation
71+
@operation(is_idempotent=False)
7272
def command(hostname, command, user=None, port=22, ssh_user=None, state=None, host=None):
7373
'''
7474
Execute commands on other servers over SSH.
@@ -102,7 +102,7 @@ def command(hostname, command, user=None, port=22, ssh_user=None, state=None, ho
102102
yield 'ssh -p {0} {1} {2}'.format(port, connection_target, command)
103103

104104

105-
@operation
105+
@operation(is_idempotent=False)
106106
def upload(
107107
hostname, filename,
108108
remote_filename=None,

pyinfra/operations/yum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def rpm(src, present=True, state=None, host=None):
112112
yield ensure_rpm(state, host, files, src, present, 'yum')
113113

114114

115-
@operation
115+
@operation(is_idempotent=False)
116116
def update(state=None, host=None):
117117
'''
118118
Updates all yum packages.

tests/operations/apk.packages/upgrade_packages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"commands": [
1010
"apk add curl"
1111
],
12-
"idempotent": false
12+
"idempotent": false,
13+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1314
}

tests/operations/apk.packages/upgrade_update.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"apk update",
1414
"apk upgrade"
1515
],
16-
"idempotent": false
16+
"idempotent": false,
17+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1718
}

tests/operations/apt.packages/update_upgrade.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"apt-get update",
1111
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" upgrade"
1212
],
13-
"idempotent": false
13+
"idempotent": false,
14+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1415
}

tests/operations/apt.packages/upgrade_packages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" install another",
1313
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" install git"
1414
],
15-
"idempotent": false
15+
"idempotent": false,
16+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1617
}

0 commit comments

Comments
 (0)