From 3f245498c4ce279c8765f4fbed30bbe00a6e84cd Mon Sep 17 00:00:00 2001 From: Tim Bielawa Date: Sat, 10 Mar 2012 14:02:25 -0500 Subject: [PATCH] Fixup RPM building: Makefile, Spec File, .gitignore Fixup distutils: setup.py Clean old cruft: section 5 man pages --- .gitignore | 4 + Makefile | 45 ++++- ansible.spec | 24 ++- docs/man/man1/ansible-playbook.1.asciidoc | 2 + docs/man/man1/ansible.1.asciidoc | 5 +- docs/man/man5/ansible-modules.5.asciidoc | 235 ---------------------- docs/man/man5/ansible-playbook.5.asciidoc | 123 ----------- setup.py | 33 ++- 8 files changed, 74 insertions(+), 397 deletions(-) delete mode 100644 docs/man/man5/ansible-modules.5.asciidoc delete mode 100644 docs/man/man5/ansible-playbook.5.asciidoc diff --git a/.gitignore b/.gitignore index ff4333a6b3..52ff4ef62b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ build # Emacs backup files... *~ .\#* +# (s)rpm building stuff +MANIFEST +dist +rpm-build diff --git a/Makefile b/Makefile index cfbeaf4079..b5915ebc5c 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,13 @@ #!/usr/bin/make +NAME = "ansible" ASCII2MAN = a2x -D $(dir $@) -d manpage -f manpage $< ASCII2HTMLMAN = a2x -D docs/html/man/ -d manpage -f xhtml MANPAGES := docs/man/man1/ansible.1 docs/man/man1/ansible-playbook.1 SITELIB = $(shell python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()") +RPMVERSION := $(shell awk '/Version/{print $$2; exit}' < ansible.spec | cut -d "%" -f1) +RPMRELEASE := $(shell awk '/Release/{print $$2; exit}' < ansible.spec | cut -d "%" -f1) +RPMNVR = "$(NAME)-$(RPMVERSION)-$(RPMRELEASE)" all: clean python @@ -45,8 +49,8 @@ clean: find ./docs/man -type f \( -name "*.xml" -or -regex ".*\.[0-9]$$" \) -delete @echo "Cleaning up output from test runs" -rm -rf test/test_data - @echo "Cleaning up RPM stuff" - -rm MANIFEST + @echo "Cleaning up RPM building stuff" + -rm -rf MANIFEST rpm-build python: docs python setup.py build @@ -54,11 +58,38 @@ python: docs install: docs python setup.py install -rpm: - python setup.py sdist - rpmbuild -ta dist/ansible-1.0.tar.gz +sdist: clean + python ./setup.py sdist + +rpmcommon: sdist + @mkdir -p rpm-build + @cp dist/*.gz rpm-build/ + +srpm: rpmcommon + @rpmbuild --define "_topdir %(pwd)/rpm-build" \ + --define "_builddir %{_topdir}" \ + --define "_rpmdir %{_topdir}" \ + --define "_srcrpmdir %{_topdir}" \ + --define "_specdir %{_topdir}" \ + --define "_sourcedir %{_topdir}" \ + -bs ansible.spec + @echo "#############################################" + @echo "Ansible SRPM is built:" + @echo " rpm-build/$(RPMNVR).src.rpm" + @echo "#############################################" + +rpm: rpmcommon + @rpmbuild --define "_topdir %(pwd)/rpm-build" \ + --define "_builddir %{_topdir}" \ + --define "_rpmdir %{_topdir}" \ + --define "_srcrpmdir %{_topdir}" \ + --define "_specdir %{_topdir}" \ + --define "_sourcedir %{_topdir}" \ + -ba ansible.spec + @echo "#############################################" + @echo "Ansible RPM is built:" + @echo " rpm-build/noarch/$(RPMNVR).noarch.rpm" + @echo "#############################################" .PHONEY: docs manual clean pep8 vpath %.asciidoc docs/man/man1 - - diff --git a/ansible.spec b/ansible.spec index b8d36012c5..8bae80f8e4 100644 --- a/ansible.spec +++ b/ansible.spec @@ -1,17 +1,21 @@ %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} -Summary: Minimal SSH command and control Name: ansible -Version: 1.0 Release: 1 -Source0: ansible-%{version}.tar.gz -License: GPLv3 -Group: Development/Libraries +Summary: Minimal SSH command and control +Version: 0.0.1 + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot +Group: Development/Libraries +License: GPLv3 Prefix: %{_prefix} +Source0: ansible-%{version}.tar.gz +Url: http://ansible.github.com + BuildArch: noarch -Url: http://github.com/mpdehaan/ansible/ BuildRequires: asciidoc +BuildRequires: python-devel + Requires: python-paramiko Requires: python-jinja2 @@ -21,7 +25,7 @@ executing commands, running "modules", or executing larger 'playbooks' that can serve as a configuration management or deployment system. %prep -%setup -n %{name}-%{version} +%setup -q -n %{name}-%{version} %build python setup.py build @@ -38,13 +42,11 @@ rm -rf $RPM_BUILD_ROOT %doc README.md AUTHORS.md PKG-INFO %defattr(-,root,root) %{_mandir}/man1/*.gz -%{_mandir}/man5/*.gz %{python_sitelib}/* %{_bindir}/ansible* %{_datadir}/ansible/* %{_sysconfdir}/ansible/ %changelog -* Mon Mar 5 2012 Seth Vidal -- spec file - +* Sat Mar 10 2012 - 0.0.1-1 +- Release of 0.0.1 diff --git a/docs/man/man1/ansible-playbook.1.asciidoc b/docs/man/man1/ansible-playbook.1.asciidoc index bc3cf9795c..cbeada15b9 100644 --- a/docs/man/man1/ansible-playbook.1.asciidoc +++ b/docs/man/man1/ansible-playbook.1.asciidoc @@ -82,6 +82,8 @@ Ansible is released under the terms of the GPLv3 License. SEE ALSO -------- +*ansible*(1) + Extensive documentation as well as IRC and mailing list info is available on the ansible home page: diff --git a/docs/man/man1/ansible.1.asciidoc b/docs/man/man1/ansible.1.asciidoc index 7c2f1f3eca..a5d70cf4f4 100644 --- a/docs/man/man1/ansible.1.asciidoc +++ b/docs/man/man1/ansible.1.asciidoc @@ -133,8 +133,7 @@ Ansible is released under the terms of the GPLv3 License. SEE ALSO -------- +*ansible-playbook*(1) + Extensive documentation as well as IRC and mailing list info is available on the ansible home page: - - - diff --git a/docs/man/man5/ansible-modules.5.asciidoc b/docs/man/man5/ansible-modules.5.asciidoc deleted file mode 100644 index afdd461b63..0000000000 --- a/docs/man/man5/ansible-modules.5.asciidoc +++ /dev/null @@ -1,235 +0,0 @@ -ansible-modules(5) -================= -:doctype:manpage -:man source: Ansible-modules -:man version: 0.0.1 -:man manual: Ansible - - -NAME ----- -ansible-modules - stock modules shipped with ansible - - -DESCRIPTION ------------ - -Ansible ships with a number of modules that can be executed directly on remote hosts or through -ansible playbooks. - - -IDEMPOTENCE ------------ - -Most modules other than command are idempotent, meaning they will seek to avoid changes -unless a change needs to be made. When using ansible playbooks, these modules can -trigger change events, as described in *ansible-playbooks*(5). - -Unless otherwise noted, all modules support change hooks. - - -command -------- - -The command module takes the command name followed by a list of arguments, space delimited. -This is the only module that does not use key=value style parameters. - -Example usage:: - -/sbin/shutdown -t now - -This module does not support change hooks. - -Returns the return code from the program as well as timing information. - -(Async command running and command execution time limits are in plan.) - -copy ----- - -The copy module moves a file on the local box to remote locations. - -*src=*:: - -Local absolute path to a file to copy to the remote server - - -*dest=*:: - -Remote absolute path where the file should end up - - -This module also returns md5sum information about the resultant file. - - -facter ------- - -Runs the discovery program 'facter' on the remote system, returning -JSON data that can be useful for inventory purposes. - -Requires that 'facter' and 'ruby-json' be installed on the remote end. - -This module is informative only - it takes no parameters & does not support change hooks, -nor does it make any changes on the system. - - -file ----- - -Ensures the ownership and permissions of files are as desired. - -Use copy or template first if you need to make sure a file is on the box. - -In plan. - - -git ---- - -Deploys software from git checkouts. - -*repo=*:: - -git or http protocol address of the repo to checkout - -*dest=*:: - -where to check it out, an absolute directory path - -*version=*:: - -what version to check out -- either the git SHA, the literal string 'HEAD', or a tag name - - -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. - -This module is information only - it takes no parameters & does not -support change hooks, nor does it make any changes on the system. - - -ping ----- - -A trivial test module, this module always returns the integer '1' on -successful contact. - -This module does not support change hooks. - -This module is informative only - it takes no parameters & does not -support change hooks, nor does it make any changes on the system. - - -service -------- - -Controls services on remote machines. - -*state=*:: - -Values are 'started', 'stopped', or 'restarted'. Started/stopped -are idempotent actions that will not run commands unless neccessary. -'restarted' will always bounce the service - - -*name=*:: - -The name of the service - - -setup ------ - -Writes a JSON file containing key/value data, for use in templating. -Call this once before using the template modules, usually as the very -first step in your playbook. - -If facter or ohai are installed, variables from these programs will also -be snapshotted into the JSON file for usage in templating. These variables -are prefixed with 'facter_' and 'ohai_" so it's easy to tell their source. - -*metadata=*:: - -Optionally overrides the default JSON file location of /etc/ansible/setup. -If used, also supply the metadata parameter to 'template'. Change if -running as a non-root remote user who does not have permissions on /etc/ansible. - -*anything=*:: - -any other parameters can be named basically anything, and set a key=value -pair in the JSON file for use in templating. - - -template --------- - -Templates a file out to a remote server. Call the setup module prior to usage. - -*src=*:: - -path of a Jinja2 formatted template on the local server - - -*dest*:: - -location to render the template on the remote server - - -*metadata*:: - -location of a JSON file to use to supply template data. Default is /etc/ansible/setup -which is the same as the default for the setup module. Change if running as a non-root -remote user who does not have permissions on /etc/ansible. - - -This module also returns md5sum information about the resultant file. - - -user ----- - -This module is in plan. - - -yum ---- - -This module is in plan. - - -WRITING YOUR OWN MODULES ------------------------- - -To write your own modules, simply follow the convention of those already available in -/usr/share/ansible. Modules must return JSON but can be written in any language. -To support change hooks, modules should return hashes, with a changed: True/False -element at the top level. Modules can also choose to indicate a failure scenario -by returning a top level 'failure' element with a True value. - - -ENVIRONMENT ------------ - -ANSIBLE_LIBRARY -- Override the default ansible module library path - - -AUTHOR ------- - -Ansible was originally written by Michael DeHaan. See the AUTHORS file -for a complete list of contributors. - -SEE ALSO --------- - -*ansible*(1) - -*ansible-playbook*(5) - -Ansible home page: diff --git a/docs/man/man5/ansible-playbook.5.asciidoc b/docs/man/man5/ansible-playbook.5.asciidoc deleted file mode 100644 index 9bbcf9a9f7..0000000000 --- a/docs/man/man5/ansible-playbook.5.asciidoc +++ /dev/null @@ -1,123 +0,0 @@ -ansible-modules(5) -================= -:doctype:manpage -:man source: Ansible-playbook -:man version: 0.0.1 -:man manual: Ansible - - -NAME ----- -ansible-playbook - format and function of an ansible playbook file - - -DESCRIPTION ------------ - -Ansible ships with 'ansible-playbook', a tool for running playbooks. -Playbooks can represent frequent tasks, desired system configurations, -or deployment processes. - - -FORMAT ------- - -Playbooks are written in YAML. - - -EXAMPLE -------- - -See: - -- https://github.com/mpdehaan/ansible/blob/master/examples/playbook.yml - -- https://github.com/mpdehaan/ansible/blob/master/examples/base.yml - -- https://github.com/mpdehaan/ansible/blob/master/examples/handlers.yml - -WHAT THE EXAMPLE MEANS ------------------------ - -Here's what playbook.yml (above) will do. - -The first pattern will select all hosts. The patterns are the same -as supported by /usr/bin/ansible. - -First, it will run all the modules specified in base.yml. Includes can -be used to implement classes of things, and if you wanted, a playbook -could consist of nothing but include files. This is an example of an -include. - -After processing base.yml, on each host we'll write for -a JSON file into /etc/ansible/setup on each remote system with the -values max_clients and http_port. - -Next, we'll use a Jinja2 template locally residing at -/srv/templates/httpd.j2 to write the Apache config file on each host, -using the previous values in that setup file. - -Next, We'll ensure that apache is running if stopped. - -The template task set up a notifier, which means if the configuration -file actually changed, we have a named handler, in this case, 'restart apache' -to run. In this case, all the notifiers come from handlers.yml, though it's -also ok to express handlers directly in the main yaml file too. Using -the include promotes reuse. - -What does the handler say? If and only if the config file changed, note that we need to restart -apache at the end of the run, otherwise, don't bother because we -already know it is running. - - -HIGH LEVEL EXPLANATION ----------------------- - -Playbooks are executed top down and can contain multiple references to -patterns. For instance, a playbook could do something to all -webservers, then do something to all database servers, then do -something different to all webservers again. - -For each pattern, the tasks in the 'tasks' list are executed in order -for all hosts in the host file matching the pattern. - -For each task, a name/action pair describes what the task is and what -ansible module to use to accomplish the task, along with any -arguments. Additional fields like 'comment:' can be added and will -be ignored, so feel free to take notes in the file. - -Most modules accept key=value format arguments. - -Handlers are like tasks, but are conditionally executed. If a module -reports a 'change', it can notify one or more handler by name. If -notified, it will run only for hosts that changed. - - -ERROR HANDLING --------------- - -If a host has a failure, the host will be ignored for the remainder -of the playbook execution. - - -ENVIRONMENT ------------ - -ANSIBLE_LIBRARY -- Override the default ansible module library path - - -AUTHOR ------- - -Ansible was originally written by Michael DeHaan. See the AUTHORS file -for a complete list of contributors. - - -SEE ALSO --------- - -*ansible*(1) - -*ansible-modules*(5) - -Ansible home page: diff --git a/setup.py b/setup.py index c70aa34796..c15e8a7831 100644 --- a/setup.py +++ b/setup.py @@ -1,34 +1,31 @@ #!/usr/bin/env python +import glob +import os +import sys + +sys.path.insert(0, os.path.abspath('lib')) +from ansible import __version__, __author__ from distutils.core import setup setup(name='ansible', - version='1.0', + version=__version__, description='Minimal SSH command and control', - author='Michael DeHaan', + author=__author__, author_email='michael.dehaan@gmail.com', - url='http://github.com/mpdehaan/ansible/', + url='http://ansible.github.com/', license='GPLv3', package_dir = { 'ansible' : 'lib/ansible' }, packages=[ 'ansible', ], data_files=[ - ('/usr/share/ansible', [ - 'library/ping', - 'library/command', - 'library/facter', - 'library/ohai', - 'library/copy', - 'library/setup', - 'library/service', - 'library/template', - 'library/git', - ]), - ('/usr/share/man/man1', [ - 'docs/man/man1/ansible.1', - 'docs/man/man1/ansible-playbook.1' - ]), + ('/usr/share/ansible', + glob.glob('library/*') + ), + ('/usr/share/man/man1', + glob.glob('docs/man/man1/*.1') + ), ], scripts=[ 'bin/ansible',