Commit graph

143 commits

Author SHA1 Message Date
Michael DeHaan
4301a33b97 Streamline code 2012-11-23 10:58:17 -05:00
Michael DeHaan
d75681abdc Merge pull request #1656 from dagwieers/setup-virtualization
Implemented more virtualization types
2012-11-23 07:55:42 -08:00
Dag Wieers
f572824c5c Implemented more virtualization types
I added all known virtualization types from the virt-what project. However, the few virt types that rely on cpuid information have not been implemented lacking native python cpuid access. (hyperv)
2012-11-22 02:48:13 +01:00
Jan-Piet Mens
d184f72aa9 DOCUMENTATION strings 2012-11-21 18:49:30 +01:00
Michael DeHaan
6f6559670f chmod -x for all module files in source checkout 2012-11-19 13:47:40 -05:00
Fabian Arrotin
1151381ab1 Fixed the way dom0/domU xen role is defined in the setup module 2012-11-06 22:49:33 +01:00
Michael DeHaan
78669c57d5 Module documentation should have options sorted 2012-11-03 18:52:59 -04:00
Michael DeHaan
8d3f73d562 pep8 fixes 2012-10-30 20:42:07 -04:00
Michael DeHaan
958b2909f8 Rename 'domainname' to 'domain' 2012-10-30 20:07:36 -04:00
Serge van Ginderachter
4ebea7acba Add domainname to ansible facts 2012-10-30 19:47:31 -04:00
Brian Coca
9d1645cbe3 fixed but in pulling data from dmesg command, wrong function to use as file for for loop
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2012-10-16 18:44:09 -04:00
Brian Coca
7ba232479e small patch to fact gathering for when no dmesg.boot exists on freebsd, mainly happens in jails
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2012-10-12 17:37:30 -04:00
Michael DeHaan
3e560234bc Fix typo in autogenerated docs 2012-10-10 08:32:41 -04:00
Jan-Piet Mens
a790c399f4 Added attribution to all module DOCUMENTATION strings 2012-10-01 12:37:51 +02:00
Stephen Fromm
c0d2d76fe9 Add LSB facts, as derived from lsb_release -a
This gathers LSB facts via lsb_release.  This complements the
platform facts collected via the platform module.  This reoprts
release, id, description, release, and codename.  It also adds
'major_release', which is the major version number of a distribution.
2012-09-29 23:58:04 -07:00
Jan-Piet Mens
af1f925eea Tweak DOCUMENTATION YAML as per latest 991 2012-09-19 16:09:26 +02:00
Michael DeHaan
26f8b30653 Merge pull request #1054 from jpmens/geturl_doc1
First attempt at standardizing DOCUMENTATION string
2012-09-19 06:09:39 -07:00
Jan-Piet Mens
952a82cca0 First attempt at standardizing DOCUMENTATION string (new DICT) 2012-09-18 14:04:43 +02:00
Michael DeHaan
9f417e3502 Merge pull request #1052 from romeotheriault/add-SunOSVirtual-facts
Adding SunOSVirtual facts
2012-09-17 17:27:43 -07:00
Romeo Theriault
62f1347f69 Adding SunOSVirtual facts 2012-09-16 23:14:06 -10:00
Stephen Fromm
dc8c0ea467 Update package manager fact innards to a list of dicts 2012-09-16 21:42:55 -07:00
Stephen Fromm
6e7b94ad32 Add pkg_mgr fact to setup
This should help facilitate playbook decision making that are not
strictly distribution specific, but more package manager.
2012-09-16 21:42:54 -07:00
Matt Coddington
3102ca41a7 make this python24 compatible 2012-09-07 22:47:03 -04:00
Michael DeHaan
a3b67ec039 Merge pull request #1005 from dagwieers/cmdline
Add /proc/cmdline information to the default facts
2012-09-06 17:51:19 -07:00
Jan-Piet Mens
cbcd04b692 Add support for RSA/DSA SSH host key detection in setup module for OS/X
s/<8spaces>/<4spaces>/g
2012-09-06 20:40:21 +02:00
Dag Wieers
cabbb9fce7 Add /proc/cmdline information to the default facts
The use-case here is that based on information in the /proc/cmdline certain actions can be taken.

A practical example in our case is that we have a play at the end of the provisioning phase that reboots the system. Since we don't want to accidentally reboot a system (or restart the network) on a production machine, having a way to separate an Anaconda post-install (sshd in chroot) with a normal system is a good way to make that distinction.

    ---
    - name: reboot
      hosts: all
      tasks:
      - action: command init 6
        only_if: "not '${ansible_cmdline.BOOT_IMAGE}'.startswith('$')"

A practical problem here is the fact that we cannot simply check whether it is set or empty:

    ---
    - name: reboot
      hosts: all
      tasks:
      - action: command init 6
        only_if: "'${ansible_cmdline.BOOT_IMAGE}'"

If ansible_cmdline was a string, a simple only_if: "'${ansible_cmdline}'.find(' BOOT_IMAGE=')" was an option, but still not very "beautiful" :-/

This implementation uses shlex.split() and uses split(sep, maxsplit=1).
2012-09-06 09:35:33 +02:00
Michael DeHaan
08a3079166 Check for ipv6 2012-09-04 21:22:47 -04:00
Michael DeHaan
b0dc015a13 Always pipe stderr in the setup module to avoid JSON interference. 2012-09-02 12:34:28 -04:00
Stephen Fromm
f0da6b191a Migrate remaining modules to use get_bin_path in module_common.py
* Migraed easy_install, pip, service, setup, and user.
* Updated fail_json message in apt_repository
* Fixed easy_install to not hardcode location of virtualenv in
  /usr/local/bin/.
* Made handling of virtualenv more consistent between easy_install and
  pip.
2012-08-29 20:26:22 -07:00
Michael DeHaan
d426afcfb2 Merge branch 'setup-no-dash-facts' of https://github.com/tima/ansible into devel
Conflicts:
	library/setup
2012-08-28 20:29:40 -04:00
Timothy Appnel
d170c51545 Replace - with _ in setup module key names to avoid variable access problems reported in #954 2012-08-28 19:02:19 -04:00
Maxim Burgerhout
f9410c94d7 Add working CPU model fact for some ARM devices
Works on Sheevaplug, probably works on Rasberry Pi as well
2012-08-24 23:11:06 +02:00
Tim Bielawa
23ec079661 Fix setup module explosion when a route is empty. Closes #909 2012-08-19 21:19:07 -04:00
Daniel Hokka Zakrisson
d1568b1ebb Work with tun and p2p interfaces 2012-08-17 22:08:04 +02:00
Sundar Raman
62e082a1c7 (Re #882) Handle errors in get_interfaces
If there is an error in how interfaces are configured (or only one set, like IPv6),
the setup command should not error out.
2012-08-15 19:22:05 -04:00
Michael DeHaan
a102507a5c Merge pull request #866 from akhayyat/devel
setup: add type and default_ipv{4,6} to linux network facts
2012-08-14 16:19:14 -07:00
Daniel Hokka Zakrisson
e79667bcad Fix spelling of architecture for non-x86 2012-08-14 15:57:54 +02:00
Ahmad Khayyat
a9ebe9cb2b setup: add type and default_ipv{4,6} to linux network facts 2012-08-14 01:37:14 -04:00
Stephen Fromm
a991c43702 Try to find ip command in either /sbin or /usr/sbin
If ip is not found in either /sbin or /usr/sbin, this will return
an empty result.  It seems extremely unlikely that a linux system will
not have iproute2 installed
2012-08-11 23:54:22 -07:00
Stephen Fromm
da58114c87 Tweak invocation of ip in LinuxNetwork
Specify full path to ip and add third argument 'show' to be explicit
about requested action.  This goes from 'ip addr' to
'/sbin/ip addr show'.
2012-08-11 23:54:22 -07:00
Michael DeHaan
4cdfebc6b8 tweak config mode check to just have a default 2012-08-11 12:38:05 -04:00
Michael DeHaan
3c2eba57fd Make pep8 tests run against the library directory as well, and associated tweaks (mostly to indentation) in the library
directory.
2012-08-11 12:35:58 -04:00
Michael DeHaan
61d10cd773 Merge pull request #850 from akhayyat/virt-facts
Add openvz detection to virtualization facts, and some cleanup
2012-08-11 09:11:01 -07:00
Michael DeHaan
97768b269a Don't include local addresses in the all_ipv4/6 list 2012-08-11 12:08:55 -04:00
Ahmad Khayyat
5de5f6e86e Add openvz detection to virtualization facts, and some cleanup 2012-08-11 08:33:43 -04:00
Ahmad Khayyat
486945e7d2 Update doc string and minor cleanup 2012-08-11 06:39:22 -04:00
Ahmad Khayyat
42fedcc810 Recognize interface aliases in network facts, and add IP facts 2012-08-11 06:20:32 -04:00
Stephen Fromm
069be5b888 Make exception more specific (OSError) in setup module for selinux call 2012-08-08 08:56:12 -07:00
Stephen Fromm
c31b86088f Protect all selinux calls with try/except 2012-08-07 22:57:44 -07:00
Michael DeHaan
5ed21bf443 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
2012-08-06 20:07:02 -04:00
Michael DeHaan
baacde6c74 Add encoding lines to python modules such that they can take unicode options if they are fed them, since the
AnsibleModule stuff no longer base64 encodes for simplicity and speed reasons.
2012-08-02 21:29:10 -04:00
Stephen Fromm
0c9f1cbffd Add Blade to FORM_FACTOR list and document SMBIOS spec URL 2012-08-02 07:24:05 -07:00
Stephen Fromm
1f2de09530 Catch exception if form factor id is unknown 2012-08-02 07:06:55 -07:00
Michael DeHaan
4782bc1949 Port the file module over to the new common code infrastructure + cleanup some redundant imports since the module code already imports those things. 2012-07-30 21:50:32 -04:00
Michael DeHaan
9019f4f292 remove unneeded imports 2012-07-28 17:15:07 -04:00
Michael DeHaan
0b909b103d Port setup module to use the common module base 2012-07-28 17:14:23 -04:00
Christoph Seitz
fa8ca9a819 Fixes locale problem with ifconfig in setup module 2012-07-24 11:10:11 +02:00
Stephen Fromm
2d6babbd63 Skip get_ipv6_facts if socket.has_ipv6 is false 2012-07-20 17:19:26 -07:00
Stephen Fromm
9f063f1d3d Update LinuxNetwork to not use fcntl and ioctls
get_interfaces() updated to read /proc/net/dev.  This means it no
longer provides only interfaces that are up.

get_iface_hwaddr() updated to read from /sys/class/net/<iface>/address.

Added get_interface_facts() to pull in mac address and interface mtu.
Can be used later for additional interface-facts.

Added get_ipv6_facts(), which reads from /proc/net/if_inet6.

get_network_facts() renamed to get_ipv4_facts().  It still calls
ifconfig to determine ipv4 facts.
2012-07-19 23:50:13 -07:00
Stephen Fromm
cf9b078619 Check if CPU is QEMU via different mechanism
The processor fact doesn't exist in LinuxVirtual.  Read /proc/cpuinfo
and check if it is QEMU.
2012-07-19 23:50:12 -07:00
Stephen Fromm
6e4e39f285 Add back erroneously deleted get_file_content() 2012-07-19 23:50:12 -07:00
Stephen Fromm
f7cf2b5301 Adjustments to behavior of Facts and subclass behavior
The Facts class and subclasses no longer take a dict argument for
instantiation.  populate() now returns self.facts.
Other changes:
- Facts.__init__() takes over most of the work from populate() so that
  subclasses can benefit from its knowledge.
- Drop setting unknown facts to 'NA' in __init__() in various
  subclasses.
- Check for presence of facts in get_virtual_facts()
- Update ansible_facts() to use facts.update(<classname>().populate())
2012-07-19 23:50:12 -07:00
Stephen Fromm
582d31cde6 Update setup module for facts derived from classes
This changes and organizes facts into a base class Facts and several
sub classes that implement the necessary functionality.  The classes
are:
- Facts: base class.  Implements basic facts that should be common to a
  number of platforms.  It is also where SSH keys and SELinux facts are
  set.
- Hardware: A subclass of Facts that should be further
  subclassed per platform for CPU, memory, and related facts.
  - LinuxHardware: subclass of Hardware for Linux platforms
  - SunOSHardware: subclass of Hardware for SunOS platforms
  - FreeBSDHardware: subclass of Hardware for FreeBSD
- Network: A subclass of Facts that that should be further
  subclassed per platform for IP, both IPv4 and IPv6, information.
  - LinuxNetwork: Currently only implementation for determining network
    facts.
- Virtual: A subclass of Facts that that should be further
  subclassed per platform to determine virtual environment facts.
  - LinuxVirtual: Currently only implementation for determining virtual
    facts.

If facts are needed for additional platforms, one of the above classes
(eg Network) can be further subclassed and implement the necessary
functionality.

In addition, it fixes get_network_facts() to work on Fedora17.  That
broke due to changes to ifconfig output.
2012-07-19 23:50:12 -07:00
Michael DeHaan
31d9111857 Setup module no longer saves to disk, as templates are mostly useful in playbooks and this allows lots of simplifications
around file pathing and removes occasional permissions conflicts depending on how things are used.
2012-07-14 11:59:12 -04:00
John Kleint
b11f23750f Use iterative MD5 hashing. 2012-07-09 13:27:47 -04:00
Dave Hatton
7293cce498 switch to hashlib.md5 or md5 instead of OS md5 commands 2012-07-09 08:52:00 +01:00
Dave Hatton
b725b972ad improve error trapping for md5 2012-07-03 12:44:37 +01:00
Michael DeHaan
bdc452c620 Remove the -D module debug flag, which no longer is functional due to sudo pty requirements, and replace with -v/--verbose.
This flag will show playbook output from non-failing commands.  -v is also added to /usr/bin/ansible, but not  yet used.

I also gutted some internals code dealing with 'invocations' which allowed the callback to know what module invoked
it.  This is not something 0.5 does or needed, so callbacks have been simplified.
2012-06-19 21:57:43 -04:00
Ludovic Claude
2a53febdf5 Add basic support for Solaris 2012-06-26 19:49:26 +02:00
Fred Alger
9cbdb6ca0a Make shell outs to md5sum work on FreeBSD and OS X
Tested with OS X local connection and Linux remote. The paths to the
md5sum and md5 commands are hardcoded to the most common location. This
will definitely fail if the commands are elsewhere, or if the md5
command doesn't support the -q 'quiet' option.
2012-06-15 00:04:01 -04:00
Michael DeHaan
5c4e496fe8 Merge pull request #426 from dagwieers/facts
Add BIOS information and fix VMware detection (supports both IDE and SCSI)
2012-05-31 18:45:52 -07:00
Stephen Fromm
8aec2a4ad0 Update get_selinux_facts in setup module
This switches to using selinux library calls instead of parsing the
output of sestatus.  This fixes issue #428 where the output was slightly
different than expected on F17.  Tested against debian (non-selinux),
centos5, centos6, and fedora17.
2012-05-30 08:42:05 -07:00
Dag Wieers
16e8c30f63 Add BIOS information and fix VMware detection (supports both IDE and SCSI disks) 2012-05-30 14:23:52 +02:00
Wes Johnson
557e4ad3b5 starting fresh, doing it 'right'
Lost commit history, but this way I'm not introducing crappy commit
history in RP
2012-05-14 14:31:53 -07:00
Cosmin Luță
3b6717245c Added a new fact: network address for an interface 2012-05-11 17:17:59 +03:00
Stephen Fromm
67ee30f135 Apply logging of arguments to modules (issue #122)
The ohai and facter modules use /usr/bin/logger to log the fact that
they have been invoked.  I added 'import os' to the ping module
so that it could have the same syslog statements as the other modules.
I separated the condensed:
    shlex.split(open(argfile, 'r').read())
into two separate statements similar to the other modules.
2012-05-09 15:19:20 -07:00
Stephen Fromm
b49b8528bf Change to socket.getfqdn() for fqdn fact 2012-04-26 08:39:47 -07:00
cocoy
73349fba36 Bugfix for issue no. 229 2012-04-25 21:02:44 +08:00
Jeroen Hoekx
08ba4928dc Allow modules to return facts.
If the module result contains "ansible_facts", that will be added to the setup
cache.
2012-04-23 21:28:12 +02:00
Stephen Fromm
cfbd9b282b Add native facts to library/setup
This collects various facts from the host so that it isn't necessary to
have facter or ohai installed.  It gets various platform/distribution
facts, information about the type of hardware, whether a virtual
environment and what type, assorted interface facts, and ssh host public
keys.  Most facts are flat.  The two exceptions are 'processor' and all
interface facts.  Interface facts are presented as:
    ansible_lo : {
        "macaddress": "00:00:00:00:00:00",
        "ipv4": { "address": "127.0.0.1", "netmask": "255.0.0.0" },
        "ipv6": [
                    { "address": "::1", "prefix": "128", "scope": "host" }
                ]
    }
2012-04-17 16:59:23 -07:00
Michael DeHaan
6f2bedc060 Allow variables coming in from the playbook and the API to be expressed as dictionaries throughout their full life cycle
such that nested data can be made available in templates and playbooks.
2012-04-10 20:58:40 -04:00
Michael DeHaan
582f83a995 Allow variable expressions to be stored as variables themselves, do some things to allow setup strings
to more easily contain spaces without being mangled, which is neccessary because of the above.
2012-03-21 20:00:48 -04:00
Michael DeHaan
36e86abc24 Correct the setup module 2012-03-14 19:06:35 -04:00
Michael DeHaan
45696d5dcc Split argsfile handling into subfunction, attempt to apply argsfile logic to setup 2012-03-14 19:05:19 -04:00
Michael DeHaan
6bee002074 Factoids and push variables via setup are now available to be templated in command args
as well as template files.  PLUS, variables are now expressed in playbooks without having
to know about the setup task, which means playbooks are simpler to read now.
2012-03-05 20:09:03 -05:00
Michael DeHaan
cb46a14a96 Setup module tests 2012-04-04 11:55:24 -04:00
Michael DeHaan
1bd1552b43 Relicensing to GPLv3, all previous committers ok'd on mailing list. 2012-02-28 19:08:09 -05:00
Michael DeHaan
2aa5821eaa If ohai is present, do the same with facter and make it available for the templating engine 2012-02-27 23:15:11 -05:00
Michael DeHaan
0ac8aab83e Include facter variables for free in setup JSON (prefix with 'facter'.
Also sort keys in JSON file and pretty print
2012-02-27 23:06:32 -05:00
Michael DeHaan
07d17e4cb4 Fixed up KV munging in runner, misc fixes to copy, setup, and template modules 2012-02-26 19:55:26 -05:00
Michael DeHaan
5e6bf63215 make copy & template module take key/value parameters so we're consistent. Only the command
module works differently now

starter manpage for modules

allow template file location to be passed into template & setup modules
2012-02-26 19:21:44 -05:00
Michael DeHaan
3e010b9500 Added remote templating engine using jinja2, see examples/playbook.yml for usage.
Cleanup is due in runner.py
2012-02-24 04:35:51 -05:00
Michael DeHaan
445a76dbdc Added a setup module which can be used to place key-value JSON data
on the system for use in a later template module.   These values
could also be used for module-specific config.
2012-02-24 03:25:09 -05:00