diff --git a/api.html b/api.html index 4cba99cbe4..115d2a3a52 100644 --- a/api.html +++ b/api.html @@ -165,7 +165,7 @@ s.parentNode.insertBefore(ga, s);

API & Integrations

There are two major ways to use Ansible from an API perspective. The primary way -is to use the Ansible python API to control nodes. Ansible is written in it’s own +is to use the Ansible python API to control nodes. Ansible is written in its own API so you have a considerable amount of power there.

Also covered here, Ansible’s list of hosts, groups, and variables assigned to each host can be driven from @@ -244,8 +244,7 @@ command line tools ansible in a different system. Frequent examples include LDAP, Cobbler, or a piece of expensive enterprisey CMDB software. Ansible easily supports all of these options via an external interventory system.

-

If you have a data store system where an Ansible external inventory script doesn’t already exist, this may require a little coding,J -but we have a Cobbler example in the main source tree – but it’s pretty simple, as we’ll explain below – that would provide a good starting point. Like with modules, it’s possible to build an external inventory script in any language, as long as it returns JSON.

+

If you have a data store system where an Ansible external inventory script doesn’t already exist, this may require a little coding, but we have a Cobbler example in the main source tree – but it’s pretty simple, as we’ll explain below – that would provide a good starting point. Like with modules, it’s possible to build an external inventory script in any language, as long as it returns JSON.

If you are familiar with Puppet terminology, this concept is basically the same as ‘external nodes’, with the slight difference that it also defines which hosts are managed.

Script Conventions

diff --git a/faq.html b/faq.html index eea46718bc..b8d165f42b 100644 --- a/faq.html +++ b/faq.html @@ -234,7 +234,7 @@ even bash ... just return some output in JSON format. You don’t need to k as it can. A system shouldn’t be half correct, especially if we’re planning on configuring other systems that depend on that system.

Ansible also has a VERY short learning curve – but it also has less language constructs and -does not create it’s own programming language. What constructs Ansible does have should be enough to cover 80% or so of the cases of most Puppet users, and it should scale equally well (not having a server is +does not create its own programming language. What constructs Ansible does have should be enough to cover 80% or so of the cases of most Puppet users, and it should scale equally well (not having a server is almost like cheating).

I also suspect some Ansible users will actually use Ansible to trigger Puppet – using the git module to checkout a Puppet module hierachy from source, and the command module to run @@ -284,7 +284,7 @@ run multiple commands in seperate forks, thanks to the magic behind Python’s multiprocessing module.

If you need to address 500 machines you can decide if you want to try to contact 5 at a time, or 50 at a time. -It’s up to you and how much power you can throw at it, but it’s heritage +It’s up to you and how much power you can throw at it, but its heritage is about handling those kinds of use cases.

There are no daemons so it’s entirely up to you. When you are aren’t using Ansible, it is not consuming any resources.

diff --git a/index.html b/index.html index cc68e9f065..60983ac516 100644 --- a/index.html +++ b/index.html @@ -220,6 +220,7 @@ you with questions about Ansible.

  • See the presentation on Speakerdeck
  • Visit the Google Group
  • Chat on FreeNode
  • +
  • View or add to the the Contrib Repo on Github
  • Google Groups
    @@ -269,6 +270,7 @@ Email:   command
  • copy
  • facter
  • +
  • fetch
  • file
  • git
  • group
  • @@ -298,6 +300,7 @@ Email:   
  • Running Operations On Change
  • Power Tricks
      +
    • Local Playbooks
    • External Variables And Prompted or Sensitive Data
    • Conditional Execution
    • Conditional Imports
    • diff --git a/moduledev.html b/moduledev.html index ef267b4029..bdc0b75c4c 100644 --- a/moduledev.html +++ b/moduledev.html @@ -212,7 +212,7 @@ chmod +x ansible/hacking/test-module

      Reading Input

      Let’s modify the module to allow setting the current time. We’ll do this by seeing if a key value pair in the form time=<string> is passed in to the module.

      -

      Ansible internally saves arguments to a arguments file. So we must read the file +

      Ansible internally saves arguments to an arguments file. So we must read the file and parse it. The arguments file is just a string, so any form of arguments are legal. Here we’ll do some basic parsing to treat the input as key=value.

      The example usage we are trying to achieve to set the time is:

      diff --git a/modules.html b/modules.html index ce7d2cf671..e72ce45152 100644 --- a/modules.html +++ b/modules.html @@ -133,6 +133,7 @@ s.parentNode.insertBefore(ga, s);
    • command
    • copy
    • facter
    • +
    • fetch
    • file
    • git
    • group
    • @@ -208,7 +209,7 @@ noted, any given module does support change hooks.

    state:

      -
    • Can be either ‘installed’, ‘removed’, or ‘latest’.
    • +
    • Can be either ‘installed’, ‘removed’, or ‘latest’. The default is ‘installed’.

    Example action from Ansible Playbooks:

    apt pkg=foo ensure=removed
    @@ -270,8 +271,24 @@ support change hooks, nor does it make any changes on the system.
     Playbooks do not actually use this module, they use the setup
     module behind the scenes.

    +
    +

    fetch

    +

    This module works like ‘copy’, but in reverse. It is used for fetching files +from remote machines and storing them locally in a file tree, organized by hostname.

    +

    src:

    +
      +
    • The file on the remote system to fetch. This needs to be a file, not a directory. Recursive fetching may be supported later.
    • +
    +

    dest:

    +
      +
    • A directory to save the file into. For example, if the ‘dest’ directory is ‘/foo’, a src file named ‘/tmp/bar’ on host ‘host.example.com’, would be saved into ‘/foo/host.example.com/bar’.
    • +
    +

    The fetch module is a useful way to gather log files from remote systems. If you require +fetching multiple files from remote systems, you may wish to execute a tar command and +then fetch the tarball.

    +
    -

    file

    +

    file

    Sets attributes of files, symlinks, and directories, or removes files/symlinks/directories. All parameters available to the file module are also available when running the copy or template modules.

    @@ -309,9 +326,10 @@ file path=/some/path owner=foo group=foo state=directory file path=/path/to/delete state=absent file src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link
    +

    The file module also supports numerous SELinux attributes (documentation on this pending).

  • -

    git

    +

    git

    Deploys software (or files) from git checkouts.

    repo:

      @@ -331,7 +349,7 @@ file src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link
    -

    group

    +

    group

    Adds or removes groups.

    name:

      @@ -351,7 +369,7 @@ file src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link
    -

    ohai

    +

    ohai

    Similar to the facter module, this returns JSON inventory data. Ohai data is a bit more verbose and nested than facter.

    Requires that ‘ohai’ be installed on the remote end.

    @@ -361,7 +379,7 @@ support change hooks, nor does it make any changes on the system.

    setup module behind the scenes instead.

    -

    ping

    +

    ping

    A trivial test module, this module always returns the integer 1 on successful contact.

    This module does not support change hooks and is informative only - it @@ -369,7 +387,7 @@ takes no parameters & does not support change hooks, nor does it make any changes on the system.

    -

    service

    +

    service

    Controls services on remote machines.

    state:

      @@ -388,7 +406,7 @@ service name=httpd state=restarted
    -

    setup

    +

    setup

    Writes a JSON file containing key/value data, for use in templating. Call this once before using the template module. Playbooks will execute this module automatically as the first step in each play @@ -410,12 +428,12 @@ tell their source. All variables are then bubbled up to the caller.

    ntpserver: 'ntp.example.com' xyz: 1234
    -

    Example action from /usr/bin/Ansible:

    -
    Ansible -m all setup -a "ntpserver=ntp.example.com xyz=1234"
    +

    Example action from /usr/bin/ansible:

    +
    ansible all -m setup -a "ntpserver=ntp.example.com xyz=1234"
    -

    shell

    +

    shell

    The shell module takes the command name followed by a list of arguments, space delimited. It is almost exactly like the command module but runs the command through the shell rather than directly.

    @@ -433,7 +451,7 @@ command was running for.

    -

    template

    +

    template

    Templates a file out to a remote server. Call the setup module prior to usage if you are not running from a playbook. In addition to the options listed below, the arguments available to the file module can also be passed to the copy @@ -453,7 +471,7 @@ be a relative or absolute path.

    -

    user

    +

    user

    Creates user accounts, manipulates existing user accounts, and removes user accounts.

    name:

    -

    virt

    +

    virt

    Manages virtual machines supported by libvirt. Requires that libvirt be installed on the managed machine.

    guest:

    @@ -535,15 +553,15 @@ ansible host -m virt -a "guest=foo command=get_xml" ansible host -m virt -a "guest=foo command=autostart"

    Example host (hypervisor) management commands from /usr/bin/ansible:

    -
    ansible host -m virt -a "freemem"
    -ansible host -m virt -a "list_vms"
    -ansible host -m virt -a "info"
    -ansible host -m virt -a "nodeinfo"
    -ansible host -m virt -a "virttype"
    +
    ansible host -m virt -a "command=freemem"
    +ansible host -m virt -a "command=list_vms"
    +ansible host -m virt -a "command=info"
    +ansible host -m virt -a "command=nodeinfo"
    +ansible host -m virt -a "command=virttype"
    -

    yum

    +

    yum

    Will install, upgrade, remove, and list packages with the yum package manager.

    pkg:

    state:

    list: