Skip to content

Commit 87a0ea4

Browse files
committed
Update the examples to use the imported config object.
1 parent 950e2bb commit 87a0ea4

File tree

17 files changed

+43
-37
lines changed

17 files changed

+43
-37
lines changed

examples/digitalocean/remove_10_ip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pyinfra import host
1+
from pyinfra import config, host
22
from pyinfra.facts.hardware import Ipv4Addresses
33
from pyinfra.operations import server
44

5-
SUDO = True
5+
config.SUDO = True
66

77
ip = host.get_fact(Ipv4Addresses)['eth0']
88

examples/docker_ce.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pyinfra import host
1+
from pyinfra import config, host
22
from pyinfra.facts.server import LinuxName, LsbRelease
33
from pyinfra.operations import apt, init, python
44

@@ -9,14 +9,17 @@
99
# Please see https://github.com/Fizzadar/pyinfra-docker
1010
# for a more complete pyinfra docker installation.
1111

12-
SUDO = True
12+
config.SUDO = True
1313
# If the remote system requires a password for sudo, un-comment the line below:
1414
# USE_SUDO_PASSWORD = True
1515

1616

1717
def check_docker_works(state, host):
1818
command = 'docker run hello-world'
19-
status, stdout, stderr = host.run_shell_command(command=command, sudo=SUDO)
19+
status, stdout, stderr = host.run_shell_command(
20+
command=command,
21+
sudo=config.SUDO,
22+
)
2023
if not status or 'Hello from Docker!' not in stdout:
2124
raise Exception('`{}` did not work as expected'.format(command))
2225

examples/files_download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pyinfra import host
1+
from pyinfra import config, host
22
from pyinfra.facts.server import LinuxName
33
from pyinfra.operations import apt, files
44

5-
SUDO = True
5+
config.SUDO = True
66

77
if host.get_fact(LinuxName) == 'Ubuntu':
88

examples/files_line_with_quotes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from pyinfra import config
12
from pyinfra.operations import files
23

3-
SUDO = True
4+
config.SUDO = True
45

56
# Run: pyinfra @docker/ubuntu files_line_with_quotes.py
67

examples/puppet/step0.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pyinfra import host
1+
from pyinfra import config, host
22
from pyinfra.facts.hardware import Ipv4Addresses
33
from pyinfra.operations import server
44

5-
SUDO = True
5+
config.SUDO = True
66

77
ip = host.get_fact(Ipv4Addresses)['eth0']
88

examples/puppet/step1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pyinfra import host, inventory
1+
from pyinfra import config, host, inventory
22
from pyinfra.facts.hardware import Ipv4Addresses
33
from pyinfra.facts.server import LinuxDistribution, LinuxName
44
from pyinfra.operations import files, init, server, yum
55

6-
SUDO = True
6+
config.SUDO = True
77

88

99
# update the /etc/hosts file

examples/puppet/step2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pyinfra import host, inventory
1+
from pyinfra import config, host, inventory
22
from pyinfra.operations import init, puppet, server
33

4-
SUDO = True
5-
USE_SUDO_LOGIN = True
4+
config.SUDO = True
5+
config.USE_SUDO_LOGIN = True
66

77
if host in inventory.get_group('master_servers'):
88
server.script_template(

examples/puppet/step3.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pyinfra import host, inventory
1+
from pyinfra import config, host, inventory
22
from pyinfra.operations import files, puppet
33

4-
SUDO = True
5-
USE_SUDO_LOGIN = True
4+
config.SUDO = True
5+
config.USE_SUDO_LOGIN = True
66

77
if host in inventory.get_group('master_servers'):
88
files.template(

examples/pxe/pxe_infra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pyinfra import host
1+
from pyinfra import config, host
22
from pyinfra.facts.server import LinuxName
33
from pyinfra.operations import apt, files, init, server
44

5-
SUDO = True
5+
config.SUDO = True
66

77
# If you change pxe_server value below then check/change Vagrantfile
88
pxe_server = '192.168.0.240'

examples/pxe_with_nfs/pxe_with_nfs_infra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pyinfra import host
1+
from pyinfra import config, host
22
from pyinfra.facts.files import File
33
from pyinfra.facts.server import LinuxName
44
from pyinfra.operations import apt, files, init, server
55

6-
SUDO = True
6+
config.SUDO = True
77

88
# If you change pxe_server value below then check/change Vagrantfile
99
pxe_server = '192.168.0.240'

0 commit comments

Comments
 (0)