From 8898643c1d454aa3138874e6d4dd2c73035630f4 Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 16:15:41 +0200 Subject: [PATCH 1/9] Added DOCUMENTATION to musql_user module. --- library/mysql_user | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/library/mysql_user b/library/mysql_user index 5a4062b68d2..e35cce3c02d 100755 --- a/library/mysql_user +++ b/library/mysql_user @@ -18,6 +18,69 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +DOCUMENTATION = ''' +--- +module: mysql_user +short_description: Adds or removes a user from a MySQL database. +description: + - Adds or removes a user from a MySQL database. +version_added: "0.6" +options: + name: + description: + - name of the user (role) to add or remove + required: true + default: null + password: + description: + - set the user's password + required: false + default: null + host: + description: + - the 'host' part of the MySQL username + required: false + default: localhost + login_user: + description: + - The username used to authenticate with + required: false + default: null + login_password: + description: + - The passwordused to authenticate with + required: false + default: null + login_host: + description: + - Host running the database + required: false + default: localhost + priv: + description: + - MySQL privileges string in the format: db.table:priv1,priv2 + required: false + default: null + state: + description: + - The database state + required: false + default: present + choices: [ "present", "absent" ] +examples: + - code: mysql_user name=bob password=12345 priv=*.*:ALL state=present + description: Create database user with name 'bob' and password '12345' with all database privileges + - code: mysql_user login_user=root login_password=123456 name=sally state=absent + description: Ensure no user named 'sally' exists, also passing in the auth credentials. + - code: mydb.*:INSERT,UPDATE/anotherdb.*:SELECT/yetanotherdb.*:ALL + description: Example privileges string format +notes: + - Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as apt-get install python-mysqldb. + - Both 'login_password' and 'login_username' are required when you are passing credentials. If none are present, the module will attempt to read the credentials from ~/.my.cnf, and finally fall back to using the MySQL default login of 'root' with no password. +requirements: [ ConfigParser ] +author: Mark Theunissen +''' + import ConfigParser try: import MySQLdb From a75348b406cac9f3266211cb7aebfe57db82bd82 Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 16:15:52 +0200 Subject: [PATCH 2/9] Added DOCUMENTATION to musql_db module. --- library/mysql_db | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/library/mysql_db b/library/mysql_db index 6752d9f7ba3..68df14ccab1 100755 --- a/library/mysql_db +++ b/library/mysql_db @@ -19,6 +19,60 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +DOCUMENTATION = ''' +--- +module: mysql_db +short_description: Add or remove MySQL databases from a remote host. +description: + - Add or remove MySQL databases from a remote host. +version_added: "0.6" +options: + name: + description: + - name of the database to add or remove + required: true + default: null + login_user: + description: + - The username used to authenticate with + required: false + default: null + login_password: + description: + - The passwordused to authenticate with + required: false + default: null + login_host: + description: + - Host running the database + required: false + default: localhost + state: + description: + - The database state + required: false + default: present + choices: [ "present", "absent" ] + collation: + description: + - Collation mode + required: false + default: null + encoding: + description: + - Encoding mode + required: false + default: null +examples: + - code: mysql_db db=bobdata state=present + description: create a new database with name 'bobdata' +notes: + - Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as apt-get install python-mysqldb. + - Both 'login_password' and 'login_username' are required when you are passing credentials. If none are present, the module will attempt to read the credentials from ~/.my.cnf, and finally fall back to using the MySQL default login of 'root' with no password. +requirements: [ ConfigParser ] +author: Mark Theunissen +''' + import ConfigParser try: import MySQLdb From 2aaaf986d30deb84b3599df755a983ce126647fd Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 16:21:00 +0200 Subject: [PATCH 3/9] Added DOCUMENTATION to ping module. --- library/ping | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/ping b/library/ping index a620a0943d2..31908743ca4 100755 --- a/library/ping +++ b/library/ping @@ -18,6 +18,20 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . + +DOCUMENTATION = ''' +--- +module: ping +short_description: Try to connect to host and return pong on success. +description: + - A trivial test module, this module always returns 'pong' on successful contact. It does not make sense in playbooks, but is useful from /usr/bin/ansible +version_added: "0.7" +examples: + - code: ansible webservers -m ping + description: Test 'webservers' status +author: +''' + def main(): module = AnsibleModule( argument_spec = dict() From 29ffed869c78f2b368beb757b7e110c6ae350cfe Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 16:23:58 +0200 Subject: [PATCH 4/9] Added ping module author in docs. --- library/ping | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ping b/library/ping index 31908743ca4..dc183274662 100755 --- a/library/ping +++ b/library/ping @@ -29,7 +29,7 @@ version_added: "0.7" examples: - code: ansible webservers -m ping description: Test 'webservers' status -author: +author: Michael DeHaan ''' def main(): From 0d0bc5e620a9332c19531b85a4d4563d1ef455e0 Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 16:28:55 +0200 Subject: [PATCH 5/9] Added DOCUMENTATION to subversion module. --- library/subversion | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/library/subversion b/library/subversion index 1b659c76697..a44894db9c8 100755 --- a/library/subversion +++ b/library/subversion @@ -18,12 +18,38 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -# I wanted to keep this simple at first, so for now this checks out -# from the given branch of a repo at a particular SHA or -# tag. Latest is not supported, you should not be doing -# that. Contribs welcome! -- MPD - -# requires subversion and grep on the client. +DOCUMENTATION = ''' +--- +module: subversion +short_description: Deploys a subversion repository. +description: + - This module is really simple, so for now this checks out from the given branch of a repo at a particular SHA or tag. Latest is not supported, you should not be doing that. +version_added: "0.7" +options: + repo: + description: + - The subversion URL to the repository. + required: true + default: null + dest: + description: + - Absolute path where the repository should be deployed. + required: true + default: null + force: + description: + - If yes, any modified files in the working repository will be discarded. If no, this module will fail if it encounters modified files. + required: false + default: yes + choices: [ "yes", "no" ] +examples: + - code: subversion repo=svn+ssh://an.example.org/path/to/repo dest=/src/checkout + description: Export subversion repository in a specified folder +notes: + - Requires subversion and grep on the client. +requirements: [ ] +author: Dane Summers +''' import re From 6184a0a31388f62d69d2381540bb0fc1379312a1 Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 16:43:21 +0200 Subject: [PATCH 6/9] Fixed doc string --- library/mysql_db | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/mysql_db b/library/mysql_db index 68df14ccab1..6082d17416e 100755 --- a/library/mysql_db +++ b/library/mysql_db @@ -39,7 +39,7 @@ options: default: null login_password: description: - - The passwordused to authenticate with + - The password used to authenticate with required: false default: null login_host: From a4620920b2804ad0da21eec31e17d940115d03dc Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 16:46:13 +0200 Subject: [PATCH 7/9] Added DOCUMENTATION to postgresql_db module. --- library/postgresql_db | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/library/postgresql_db b/library/postgresql_db index fdccd14ddbd..65c0d0685d0 100755 --- a/library/postgresql_db +++ b/library/postgresql_db @@ -16,6 +16,55 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +DOCUMENTATION = ''' +--- +module: postgresql_db +short_description: Add or remove PostgreSQL databases from a remote host. +description: + - Add or remove PostgreSQL databases from a remote host. +version_added: "0.6" +options: + name: + description: + - name of the database to add or remove + required: true + default: null + login_user: + description: + - The username used to authenticate with + required: false + default: null + login_password: + description: + - The passwordused to authenticate with + required: false + default: null + login_host: + description: + - Host running the database + required: false + default: localhost + owner: + description: + - Name of the role to set as owner of the database + required: false + default: null + state: + description: + - The database state + required: false + default: present + choices: [ "present", "absent" ] +examples: + - code: postgresql_db db=acme + description: create a new database with name 'acme' +notes: + - The default authentication assumes that you are either logging in as or sudo'ing to the postgres account on the host. + - This module uses psycopg2, a Python PostgreSQL database adapter. You must ensure that psycopg2 is installed on the host before using this module. If the remote host is the PostgreSQL server (which is the default case), then PostgreSQL must also be installed on the remote host. For Ubuntu-based systems, install the postgresql, libpq-dev, and python-psycopg2 packages on the remote host before using this module. +requirements: [ psycopg2 ] +author: Lorin Hochstein +''' + try: import psycopg2 except ImportError: From e30e9a74c2c2ec1063d4acffe2771dab30b30d13 Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 16:46:30 +0200 Subject: [PATCH 8/9] Added DOCUMENTATION to postgresql_user module. --- library/postgresql_user | 73 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/library/postgresql_user b/library/postgresql_user index 8f85988770d..99de1414b2d 100755 --- a/library/postgresql_user +++ b/library/postgresql_user @@ -16,6 +16,79 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +DOCUMENTATION = ''' +--- +module: postgresql_user +short_description: Adds or removes a users (roles) from a PostgreSQL database. +description: + - Add or remove PostgreSQL users (roles) from a remote host and, optionally, grant the users access to an existing database or tables. + - The fundamental function of the module is to create, or delete, roles from a PostgreSQL cluster. Privilege assignment, or removal, is an optional step, which works on one database at a time. This allows for the module to be called several times in the same module to modify the permissions on different databases, or to grant permissions to already existing users. + - A user cannot be removed untill all the privileges have been stripped from the user. In such situation, if the module tries to remove the user it will fail. To avoid this from happening the fail_on_user option signals the module to try to remove the user, but if not possible keep going; the module will report if changes happened and separately if the user was removed or not. +version_added: "0.6" +options: + name: + description: + - name of the user (role) to add or remove + required: true + default: null + password: + description: + - set the user's password + required: true + default: null + db: + description: + - name of database where permissions will be granted + required: false + default: null + fail_on_user: + description: + - if yes, fail when user can't be removed. Otherwise just log and continue + required: false + default: yes + choices: [ "yes", "no" ] + login_user: + description: + - User (role) used to authenticate with PostgreSQL + required: false + default: postgres + login_password: + description: + - Password used to authenticate with PostgreSQL + required: false + default: null + login_host: + description: + - Host running PostgreSQL. + required: false + default: localhost + priv: + description: + - PostgreSQL privileges string in the format: table:priv1,priv2 + required: false + default: null + state: + description: + - The database state + required: false + default: present + choices: [ "present", "absent" ] +examples: + - code: postgresql_user db=acme user=django password=ceec4eif7ya priv=CONNECT/products:ALL + description: Create django user and grant access to database and products table + - code: postgresql_user db=acme user=test priv=ALL/products:ALL state=absent fail_on_user=no + description: Remove test user privileges from acme + - code: postgresql_user db=test user=test priv=ALL state=absent + description: Remove test user from test database and the cluster + - code: INSERT,UPDATE/table:SELECT/anothertable:ALL + description: Example privileges string format +notes: + - The default authentication assumes that you are either logging in as or sudo'ing to the postgres account on the host. + - This module uses psycopg2, a Python PostgreSQL database adapter. You must ensure that psycopg2 is installed on the host before using this module. If the remote host is the PostgreSQL server (which is the default case), then PostgreSQL must also be installed on the remote host. For Ubuntu-based systems, install the postgresql, libpq-dev, and python-psycopg2 packages on the remote host before using this module. +requirements: [ psycopg2 ] +author: Lorin Hochstein +''' + import re try: From e1c83b036789ee8013a0ae64f1fbbedff5dd665b Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 29 Sep 2012 18:23:13 +0200 Subject: [PATCH 9/9] Fixed error on official docs (reported on DOCUMENTATION string). Name param must be pkg and is required. --- library/apt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/apt b/library/apt index ddacdf190c5..ed5420f3110 100755 --- a/library/apt +++ b/library/apt @@ -27,10 +27,10 @@ description: - Manages apt-packages (such as for Debian/Ubuntu). version_added: "0.0.2" options: - name: + pkg: description: - A package name or package specifier with version, like C(foo) or C(foo=1.0) - required: false + required: true default: null state: description: