mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 22:31:25 -07:00
docs rebuild
This commit is contained in:
parent
1952bd0aa3
commit
2c6dd03229
16 changed files with 333 additions and 223 deletions
|
@ -12,7 +12,7 @@ Examples
|
|||
Parallelism and Shell Commands
|
||||
``````````````````````````````
|
||||
|
||||
Reboot all web servers in Atlanta, 10 at a time::
|
||||
Let's use ansible's command line tool to reboot all web servers in Atlanta, 10 at a time::
|
||||
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa.pub
|
||||
|
@ -21,23 +21,24 @@ Reboot all web servers in Atlanta, 10 at a time::
|
|||
|
||||
The -f 10 specifies the usage of 10 simultaneous processes.
|
||||
|
||||
Note that other than the command module, ansible modules do not work like simple scripts. They make the remote system look like you state, and run the commands neccessary to get it there.
|
||||
|
||||
|
||||
Example 2: Time Limited Background Operations
|
||||
`````````````````````````````````````````````
|
||||
Note that other than the command module, ansible modules do not work like simple scripts. They make the remote system look like you state, and run the commands neccessary to get it there. This is commonly refered to
|
||||
as 'idempotency'.
|
||||
|
||||
Time Limited Background Operations
|
||||
``````````````````````````````````
|
||||
|
||||
Long running operations can be backgrounded, and their status can be checked on later. The same job ID is given to the same task on all hosts, so you won't lose track. Polling support is pending in the command line.::
|
||||
|
||||
ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
|
||||
ansible all -n job_status -a jid=123456789
|
||||
|
||||
Any module other than 'copy' or 'template' can be backgrounded.
|
||||
Any module other than 'copy' or 'template' can be backgrounded. Typically you'll be backgrounding shell
|
||||
commands or software upgrades only.
|
||||
|
||||
After the time limit (in seconds) runs out (-B), the process on the remote nodes will be killed.
|
||||
|
||||
Examples 3: File Transfer & Templating
|
||||
``````````````````````````````````````
|
||||
File Transfer & Templating
|
||||
``````````````````````````
|
||||
|
||||
Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.
|
||||
|
||||
|
@ -45,7 +46,7 @@ To just transfer a file directly to many different servers::
|
|||
|
||||
ansible atlanta copy -a "/etc/hosts /tmp/hosts"
|
||||
|
||||
To use templating, first run the setup module to put the template variables you would like to use on the remote host. Then use the template module to write the files using the templates. Templates are written in Jinja2 format. Playbooks (covered below) will run the setup module for you, making this even simpler.::
|
||||
To use templating, first run the setup module to put the template variables you would like to use on the remote host. Then use the template module to write the files using the templates. Templates are written in Jinja2 format. Playbooks (covered elsewhere in the documentation) will run the setup module for you, making this even simpler.::
|
||||
|
||||
ansible webservers -m setup -a "favcolor=red ntp_server=192.168.1.1"
|
||||
ansible webservers -m template -a "src=/srv/motd.j2 dest=/etc/motd"
|
||||
|
@ -53,8 +54,8 @@ To use templating, first run the setup module to put the template variables you
|
|||
|
||||
Need something like the fqdn in a template? If facter or ohai are installed, data from these projects will also be made available to the template engine, using 'facter' and 'ohai' prefixes for each.
|
||||
|
||||
Examples 3: Deploying From Source Control
|
||||
`````````````````````````````````````````
|
||||
Deploying From Source Control
|
||||
`````````````````````````````
|
||||
|
||||
Deploy your webapp straight from git::
|
||||
|
||||
|
@ -62,4 +63,15 @@ Deploy your webapp straight from git::
|
|||
|
||||
Since ansible modules can notify change handlers (see 'Playbooks') it is possible to tell ansible to run specific tasks when the code is updated, such as deploying Perl/Python/PHP/Ruby directly from git and then restarting apache.
|
||||
|
||||
Managing Services
|
||||
`````````````````
|
||||
|
||||
Ensure a service is started on all webservers::
|
||||
|
||||
ansible webservers -m service name=httpd state=started
|
||||
|
||||
Alternatively, restart a service on all webservers::
|
||||
|
||||
ansible webservers -m service name=httpd state=restarted
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue