Fabric
De Linuxmemo.
(Différences entre les versions)
(→Commande "fab") |
|||
| Ligne 14 : | Ligne 14 : | ||
fab -H localhost -f fabfile.py fonction | fab -H localhost -f fabfile.py fonction | ||
fab -H localhost -f fabfile.py -l | fab -H localhost -f fabfile.py -l | ||
| + | |||
| + | |||
| + | |||
| + | -a, --no_agent | ||
| + | Sets env.no_agent to True, forcing our SSH layer not to talk to the SSH agent when trying to unlock private key files. | ||
| + | New in version 0.9.1. | ||
| + | |||
| + | -A, --forward-agent | ||
| + | Sets env.forward_agent to True, enabling agent forwarding. | ||
| + | New in version 1.4. | ||
| + | |||
| + | --abort-on-prompts | ||
| + | Sets env.abort_on_prompts to True, forcing Fabric to abort whenever it would prompt for input. | ||
| + | New in version 1.1. | ||
| + | |||
| + | -c RCFILE, --config=RCFILE | ||
| + | Sets env.rcfile to the given file path, which Fabric will try to load on startup and use to update environment variables. | ||
| + | |||
| + | -d COMMAND, --display=COMMAND | ||
| + | Prints the entire docstring for the given task, if there is one. Does not currently print out the task’s function signature, so descriptive docstrings are a good idea. (They’re always a good idea, of course – just moreso here.) | ||
| + | |||
| + | --connection-attempts=M, -n M | ||
| + | Set number of times to attempt connections. Sets env.connection_attempts. | ||
| + | See also | ||
| + | env.connection_attempts, env.timeout | ||
| + | New in version 1.4. | ||
| + | |||
| + | -D, --disable-known-hosts | ||
| + | Sets env.disable_known_hosts to True, preventing Fabric from loading the user’s SSH known_hosts file. | ||
| + | |||
| + | -f FABFILE, --fabfile=FABFILE | ||
| + | The fabfile name pattern to search for (defaults to fabfile.py), or alternately an explicit file path to load as the fabfile (e.g. /path/to/my/fabfile.py.) | ||
| + | See also | ||
| + | Fabfile construction and use | ||
| + | |||
| + | -F LIST_FORMAT, --list-format=LIST_FORMAT | ||
| + | Allows control over the output format of --list. short is equivalent to --shortlist, normal is the same as simply omitting this option entirely (i.e. the default), and nested prints out a nested namespace tree. | ||
| + | New in version 1.1. | ||
| + | See also | ||
| + | --shortlist, --list | ||
| + | |||
| + | -h, --help | ||
| + | Displays a standard help message, with all possible options and a brief overview of what they do, then exits. | ||
| + | |||
| + | --hide=LEVELS | ||
| + | A comma-separated list of output levels to hide by default. | ||
| + | |||
| + | -H HOSTS, --hosts=HOSTS | ||
| + | Sets env.hosts to the given comma-delimited list of host strings. | ||
| + | |||
| + | -x HOSTS, --exclude-hosts=HOSTS | ||
| + | Sets env.exclude_hosts to the given comma-delimited list of host strings to then keep out of the final host list. | ||
| + | New in version 1.1. | ||
| + | |||
| + | -i KEY_FILENAME | ||
| + | When set to a file path, will load the given file as an SSH identity file (usually a private key.) This option may be repeated multiple times. Sets (or appends to) env.key_filename. | ||
| + | |||
| + | -k | ||
| + | Sets env.no_keys to True, forcing the SSH layer to not look for SSH private key files in one’s home directory. | ||
| + | New in version 0.9.1. | ||
| + | |||
| + | --keepalive=KEEPALIVE | ||
| + | Sets env.keepalive to the given (integer) value, specifying an SSH keepalive interval. | ||
| + | New in version 1.1. | ||
| + | |||
| + | --linewise | ||
| + | Forces output to be buffered line-by-line instead of byte-by-byte. Often useful or required for parallel execution. | ||
| + | New in version 1.3. | ||
| + | |||
| + | -l, --list | ||
| + | Imports a fabfile as normal, but then prints a list of all discovered tasks and exits. Will also print the first line of each task’s docstring, if it has one, next to it (truncating if necessary.) | ||
| + | Changed in version 0.9.1: Added docstring to output. | ||
| + | See also | ||
| + | --shortlist, --list-format | ||
| + | |||
| + | -p PASSWORD, --password=PASSWORD | ||
| + | Sets env.password to the given string; it will then be used as the default password when making SSH connections or calling the sudo program. | ||
| + | |||
| + | -P, --parallel | ||
| + | Sets env.parallel to True, causing tasks to run in parallel. | ||
| + | New in version 1.3. | ||
| + | See also | ||
| + | Parallel execution | ||
| + | |||
| + | --no-pty | ||
| + | Sets env.always_use_pty to False, causing all run/sudo calls to behave as if one had specified pty=False. | ||
| + | New in version 1.0. | ||
| + | |||
| + | -r, --reject-unknown-hosts | ||
| + | Sets env.reject_unknown_hosts to True, causing Fabric to abort when connecting to hosts not found in the user’s SSH known_hosts file. | ||
| + | |||
| + | -R ROLES, --roles=ROLES | ||
| + | Sets env.roles to the given comma-separated list of role names. | ||
| + | |||
| + | --set KEY=VALUE,... | ||
| + | Allows you to set default values for arbitrary Fabric env vars. Values set this way have a low precedence – they will not override more specific env vars which are also specified on the command line. E.g.: | ||
| + | fab --set password=foo --password=bar | ||
| + | will result in env.password = 'bar', not 'foo' | ||
| + | Multiple KEY=VALUE pairs may be comma-separated, e.g. fab --set var1=val1,var2=val2. | ||
| + | Other than basic string values, you may also set env vars to True by omitting the =VALUE (e.g. fab --set KEY), and you may set values to the empty string (and thus a False-equivalent value) by keeping the equals sign, but omitting VALUE (e.g. fab --set KEY=.) | ||
| + | New in version 1.4. | ||
| + | |||
| + | -s SHELL, --shell=SHELL | ||
| + | Sets env.shell to the given string, overriding the default shell wrapper used to execute remote commands. | ||
| + | |||
| + | --shortlist | ||
| + | Similar to --list, but without any embellishment, just task names separated by newlines with no indentation or docstrings. | ||
| + | New in version 0.9.2. | ||
| + | See also | ||
| + | --list | ||
| + | |||
| + | --show=LEVELS | ||
| + | A comma-separated list of output levels to be added to those that are shown by default. | ||
| + | See also | ||
| + | run, sudo | ||
| + | |||
| + | --ssh-config-path | ||
| + | Sets env.ssh_config_path. | ||
| + | New in version 1.4. | ||
| + | See also | ||
| + | Leveraging native SSH config files | ||
| + | |||
| + | --skip-bad-hosts | ||
| + | Sets env.skip_bad_hosts, causing Fabric to skip unavailable hosts. | ||
| + | New in version 1.4. | ||
| + | |||
| + | --timeout=N, -t N | ||
| + | Set connection timeout in seconds. Sets env.timeout. | ||
| + | See also | ||
| + | env.timeout, env.connection_attempts | ||
| + | New in version 1.4. | ||
| + | |||
| + | -u USER, --user=USER | ||
| + | Sets env.user to the given string; it will then be used as the default username when making SSH connections. | ||
| + | |||
| + | -V, --version | ||
| + | Displays Fabric’s version number, then exits. | ||
| + | |||
| + | -w, --warn-only | ||
| + | Sets env.warn_only to True, causing Fabric to continue execution even when commands encounter error conditions. | ||
| + | |||
| + | -z, --pool-size | ||
| + | Sets env.pool_size, which specifies how many processes to run concurrently during parallel execution. | ||
| + | New in version 1.3. | ||
==Fichier de commande: "fabfile"== | ==Fichier de commande: "fabfile"== | ||
Version du 1 juillet 2012 à 14:39
http://docs.fabfile.org/en/1.4.2/index.html
Sommaire |
Installation
apt-get install fabric
ou bien
apt-get install python-pip pip install fabric
Commande "fab"
fab -H localhost,linuxbox fonction fab -R role fonction
fab -H localhost -f fabfile.py fonction fab -H localhost -f fabfile.py -l
-a, --no_agent
Sets env.no_agent to True, forcing our SSH layer not to talk to the SSH agent when trying to unlock private key files. New in version 0.9.1.
-A, --forward-agent
Sets env.forward_agent to True, enabling agent forwarding. New in version 1.4.
--abort-on-prompts
Sets env.abort_on_prompts to True, forcing Fabric to abort whenever it would prompt for input. New in version 1.1.
-c RCFILE, --config=RCFILE
Sets env.rcfile to the given file path, which Fabric will try to load on startup and use to update environment variables.
-d COMMAND, --display=COMMAND
Prints the entire docstring for the given task, if there is one. Does not currently print out the task’s function signature, so descriptive docstrings are a good idea. (They’re always a good idea, of course – just moreso here.)
--connection-attempts=M, -n M
Set number of times to attempt connections. Sets env.connection_attempts. See also env.connection_attempts, env.timeout New in version 1.4.
-D, --disable-known-hosts
Sets env.disable_known_hosts to True, preventing Fabric from loading the user’s SSH known_hosts file.
-f FABFILE, --fabfile=FABFILE
The fabfile name pattern to search for (defaults to fabfile.py), or alternately an explicit file path to load as the fabfile (e.g. /path/to/my/fabfile.py.) See also Fabfile construction and use
-F LIST_FORMAT, --list-format=LIST_FORMAT
Allows control over the output format of --list. short is equivalent to --shortlist, normal is the same as simply omitting this option entirely (i.e. the default), and nested prints out a nested namespace tree. New in version 1.1. See also --shortlist, --list
-h, --help
Displays a standard help message, with all possible options and a brief overview of what they do, then exits.
--hide=LEVELS
A comma-separated list of output levels to hide by default.
-H HOSTS, --hosts=HOSTS
Sets env.hosts to the given comma-delimited list of host strings.
-x HOSTS, --exclude-hosts=HOSTS
Sets env.exclude_hosts to the given comma-delimited list of host strings to then keep out of the final host list. New in version 1.1.
-i KEY_FILENAME
When set to a file path, will load the given file as an SSH identity file (usually a private key.) This option may be repeated multiple times. Sets (or appends to) env.key_filename.
-k
Sets env.no_keys to True, forcing the SSH layer to not look for SSH private key files in one’s home directory. New in version 0.9.1.
--keepalive=KEEPALIVE
Sets env.keepalive to the given (integer) value, specifying an SSH keepalive interval. New in version 1.1.
--linewise
Forces output to be buffered line-by-line instead of byte-by-byte. Often useful or required for parallel execution. New in version 1.3.
-l, --list
Imports a fabfile as normal, but then prints a list of all discovered tasks and exits. Will also print the first line of each task’s docstring, if it has one, next to it (truncating if necessary.) Changed in version 0.9.1: Added docstring to output. See also --shortlist, --list-format
-p PASSWORD, --password=PASSWORD
Sets env.password to the given string; it will then be used as the default password when making SSH connections or calling the sudo program.
-P, --parallel
Sets env.parallel to True, causing tasks to run in parallel. New in version 1.3. See also Parallel execution
--no-pty
Sets env.always_use_pty to False, causing all run/sudo calls to behave as if one had specified pty=False. New in version 1.0.
-r, --reject-unknown-hosts
Sets env.reject_unknown_hosts to True, causing Fabric to abort when connecting to hosts not found in the user’s SSH known_hosts file.
-R ROLES, --roles=ROLES
Sets env.roles to the given comma-separated list of role names.
--set KEY=VALUE,...
Allows you to set default values for arbitrary Fabric env vars. Values set this way have a low precedence – they will not override more specific env vars which are also specified on the command line. E.g.: fab --set password=foo --password=bar will result in env.password = 'bar', not 'foo' Multiple KEY=VALUE pairs may be comma-separated, e.g. fab --set var1=val1,var2=val2. Other than basic string values, you may also set env vars to True by omitting the =VALUE (e.g. fab --set KEY), and you may set values to the empty string (and thus a False-equivalent value) by keeping the equals sign, but omitting VALUE (e.g. fab --set KEY=.) New in version 1.4.
-s SHELL, --shell=SHELL
Sets env.shell to the given string, overriding the default shell wrapper used to execute remote commands.
--shortlist
Similar to --list, but without any embellishment, just task names separated by newlines with no indentation or docstrings. New in version 0.9.2. See also --list
--show=LEVELS
A comma-separated list of output levels to be added to those that are shown by default. See also run, sudo
--ssh-config-path
Sets env.ssh_config_path. New in version 1.4. See also Leveraging native SSH config files
--skip-bad-hosts
Sets env.skip_bad_hosts, causing Fabric to skip unavailable hosts. New in version 1.4.
--timeout=N, -t N
Set connection timeout in seconds. Sets env.timeout. See also env.timeout, env.connection_attempts New in version 1.4.
-u USER, --user=USER
Sets env.user to the given string; it will then be used as the default username when making SSH connections.
-V, --version
Displays Fabric’s version number, then exits.
-w, --warn-only
Sets env.warn_only to True, causing Fabric to continue execution even when commands encounter error conditions.
-z, --pool-size
Sets env.pool_size, which specifies how many processes to run concurrently during parallel execution. New in version 1.3.
Fichier de commande: "fabfile"
Variables d’environnement
abort_on_prompts all_hosts always_use_pty combine_stderr command command_prefixes connection_attempts cwd disable_known_hosts exclude_hosts fabfile host_string forward_agent host hosts keepalive key_filename linewise local_user no_agent no_keys parallel password passwords path pool_size port real_fabfile rcfile reject_unknown_hosts roledefs roles shell skip_bad_hosts ssh_config_path sudo_prefix sudo_prompt timeout use_shell use_ssh_config user version warn_only