Skip to content

Commit a300d05

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

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
}

tests/operations/brew.casks/add_casks_upgrade.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
"brew cask upgrade",
1212
"brew cask install keepassxc"
1313
],
14-
"idempotent": false
14+
"idempotent": false,
15+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1516
}

tests/operations/brew.packages/upgrade_packages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"second_output_commands": [
1313
"brew upgrade php"
1414
],
15-
"idempotent": false
15+
"idempotent": false,
16+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1617
}

tests/operations/brew.packages/upgrade_update.json

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

tests/operations/dnf.packages/update_clean.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
"dnf clean all",
1212
"dnf update -y"
1313
],
14-
"idempotent": false
14+
"idempotent": false,
15+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1516
}

tests/operations/pacman.packages/upgrade_update.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"pacman -Sy",
1717
"pacman --noconfirm -Su"
1818
],
19-
"idempotent": false
19+
"idempotent": false,
20+
"disable_itempotent_warning_reason": "package upgrades are always executed"
2021
}

tests/operations/pip.packages/install_requirements.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"commands": [
77
"pip install -r requirements.txt"
88
],
9-
"idempotent": false
9+
"idempotent": false,
10+
"disable_itempotent_warning_reason": "pip package requirements are always executed"
1011
}

tests/operations/pip.packages/install_virtualenv_requirements.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
"commands": [
1212
"testdir/bin/pip install -r requirements.pip"
1313
],
14-
"idempotent": false
14+
"idempotent": false,
15+
"disable_itempotent_warning_reason": "pip package requirements are always executed"
1516
}

tests/operations/pip.packages/uninstall_requirements.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"commands": [
88
"pip uninstall --yes -r requirements.txt"
99
],
10-
"idempotent": false
10+
"idempotent": false,
11+
"disable_itempotent_warning_reason": "pip package requirements are always executed"
1112
}

tests/operations/puppet.agent/run_agent.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"commands": [
77
"puppet agent -t --server=my-server.net --masterport=3006"
88
],
9-
"idempotent": false
9+
"idempotent": false,
10+
"disable_itempotent_warning_reason": "puppet agent is always executed"
1011
}

tests/operations/python.call/call_func.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"commands": [
77
["__func__", ["arg1", "arg2"], {"hello": "world"}]
88
],
9-
"idempotent": false
9+
"idempotent": false,
10+
"disable_itempotent_warning_reason": "python callbacks are always executed"
1011
}

tests/operations/python.raise_exception/call_func.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"commands": [
44
["raise_exc", ["arg1", "arg2"], {}]
55
],
6-
"idempotent": false
6+
"idempotent": false,
7+
"disable_itempotent_warning_reason": "python callbacks are always executed"
78
}

tests/operations/xbps.packages/upgrade_update.json

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

tests/operations/yum.packages/update_clean.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
"yum clean all",
1212
"yum update -y"
1313
],
14-
"idempotent": false
14+
"idempotent": false,
15+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1516
}

tests/operations/zypper.packages/update_clean.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"zypper clean --all",
1111
"zypper update -y"
1212
],
13-
"idempotent": false
13+
"idempotent": false,
14+
"disable_itempotent_warning_reason": "package upgrades are always executed"
1415
}

0 commit comments

Comments
 (0)