Skip to content

Commit

Permalink
Expand idempotency flags on operations & operation tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Nov 13, 2021
1 parent a284fdd commit 7283f84
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pyinfra/operations/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def update(cache_time=None, touch_periodic=False, state=None, host=None):
_update = update # noqa: E305


@operation
@operation(is_idempotent=False)
def upgrade(state, host):
'''
Upgrades all apt packages.
Expand Down
6 changes: 3 additions & 3 deletions pyinfra/operations/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pyinfra.facts.mysql import make_execute_mysql_command, make_mysql_command


@operation
@operation(is_idempotent=False)
def sql(
sql,
database=None,
Expand Down Expand Up @@ -511,7 +511,7 @@ def privileges(
_privileges = privileges # noqa: E305 (for use where kwarg is the same)


@operation
@operation(is_idempotent=False)
def dump(
dest, database=None,
# Details for speaking to MySQL via `mysql` CLI
Expand Down Expand Up @@ -547,7 +547,7 @@ def dump(
), dest)


@operation
@operation(is_idempotent=False)
def load(
src, database=None,
# Details for speaking to MySQL via `mysql` CLI
Expand Down
6 changes: 3 additions & 3 deletions pyinfra/operations/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pyinfra.facts.postgresql import make_execute_psql_command, make_psql_command


@operation
@operation(is_idempotent=False)
def sql(
sql,
database=None,
Expand Down Expand Up @@ -235,7 +235,7 @@ def database(
host.noop('postgresql database {0} exists'.format(database))


@operation
@operation(is_idempotent=False)
def dump(
dest, database=None,
# Details for speaking to PostgreSQL via `psql` CLI
Expand Down Expand Up @@ -273,7 +273,7 @@ def dump(
), '>', dest)


@operation
@operation(is_idempotent=False)
def load(
src, database=None,
# Details for speaking to PostgreSQL via `psql` CLI
Expand Down
10 changes: 5 additions & 5 deletions pyinfra/operations/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from .util.files import chmod, sed_replace


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


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


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


@operation
@operation(is_idempotent=False)
def script(src, state=None, host=None):
'''
Upload and execute a local script on the remote host.
Expand All @@ -180,7 +180,7 @@ def script(src, state=None, host=None):
yield temp_file


@operation
@operation(is_idempotent=False)
def script_template(src, state=None, host=None, **data):
'''
Generate, upload and execute a local script template on the remote host.
Expand Down
4 changes: 2 additions & 2 deletions pyinfra/operations/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _user_or_ssh_user(user, ssh_user):
return user or ssh_user


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


@operation
@operation(is_idempotent=False)
def upload(
hostname, filename,
remote_filename=None,
Expand Down
2 changes: 1 addition & 1 deletion pyinfra/operations/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def rpm(src, present=True, state=None, host=None):
yield ensure_rpm(state, host, files, src, present, 'yum')


@operation
@operation(is_idempotent=False)
def update(state=None, host=None):
'''
Updates all yum packages.
Expand Down
3 changes: 2 additions & 1 deletion tests/operations/apk.packages/upgrade_packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"commands": [
"apk add curl"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/apk.packages/upgrade_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"apk update",
"apk upgrade"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/apt.packages/update_upgrade.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"apt-get update",
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" upgrade"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/apt.packages/upgrade_packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" install another",
"DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" install git"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/brew.casks/add_casks_upgrade.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"brew cask upgrade",
"brew cask install keepassxc"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/brew.packages/upgrade_packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"second_output_commands": [
"brew upgrade php"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/brew.packages/upgrade_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"brew update",
"brew upgrade"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/dnf.packages/update_clean.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"dnf clean all",
"dnf update -y"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/pacman.packages/upgrade_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"pacman -Sy",
"pacman --noconfirm -Su"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/pip.packages/install_requirements.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"commands": [
"pip install -r requirements.txt"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "pip package requirements are always executed"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"commands": [
"testdir/bin/pip install -r requirements.pip"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "pip package requirements are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/pip.packages/uninstall_requirements.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"commands": [
"pip uninstall --yes -r requirements.txt"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "pip package requirements are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/puppet.agent/run_agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"commands": [
"puppet agent -t --server=my-server.net --masterport=3006"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "puppet agent is always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/python.call/call_func.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"commands": [
["__func__", ["arg1", "arg2"], {"hello": "world"}]
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "python callbacks are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/python.raise_exception/call_func.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"commands": [
["raise_exc", ["arg1", "arg2"], {}]
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "python callbacks are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/xbps.packages/upgrade_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"xbps-install -S",
"xbps-install -y -u"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/yum.packages/update_clean.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"yum clean all",
"yum update -y"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}
3 changes: 2 additions & 1 deletion tests/operations/zypper.packages/update_clean.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"zypper clean --all",
"zypper update -y"
],
"idempotent": false
"idempotent": false,
"disable_itempotent_warning_reason": "package upgrades are always executed"
}

0 comments on commit 7283f84

Please sign in to comment.