From 06a8f1d79bb06f69d759fdd4ba7dfc6a8c944c4c Mon Sep 17 00:00:00 2001 From: Fabio Alessandro Locati Date: Thu, 1 Dec 2016 16:07:13 +0000 Subject: [PATCH] Use native YAML - Packaging (#3588) * Fix kibana * More native YAML * More native YAML * More native YAML * More native YAML. Now only languages/ is missing * Use native yaml sintax for packaging/languages as well * Some more and quote fixes * Fix wrong grouping --- .../extras/packaging/dpkg_selections.py | 4 +- .../extras/packaging/elasticsearch_plugin.py | 13 +++-- .../modules/extras/packaging/kibana_plugin.py | 13 +++-- .../extras/packaging/language/bower.py | 39 ++++++++++----- .../extras/packaging/language/bundler.py | 20 ++++++-- .../extras/packaging/language/composer.py | 18 +++---- .../extras/packaging/language/cpanm.py | 30 ++++++++---- .../packaging/language/maven_artifact.py | 26 ++++++++-- .../modules/extras/packaging/language/npm.py | 34 +++++++++---- .../modules/extras/packaging/language/pear.py | 16 +++++-- .../modules/extras/packaging/os/apk.py | 40 ++++++++++++---- .../modules/extras/packaging/os/dnf.py | 30 ++++++++---- .../modules/extras/packaging/os/homebrew.py | 48 +++++++++++++++---- .../extras/packaging/os/homebrew_cask.py | 27 +++++++++-- .../extras/packaging/os/homebrew_tap.py | 18 +++++-- .../modules/extras/packaging/os/layman.py | 20 ++++++-- .../modules/extras/packaging/os/macports.py | 25 ++++++++-- .../extras/packaging/os/openbsd_pkg.py | 33 +++++++++---- .../modules/extras/packaging/os/opkg.py | 26 ++++++++-- .../modules/extras/packaging/os/pacman.py | 33 +++++++++---- .../modules/extras/packaging/os/pkg5.py | 7 ++- .../extras/packaging/os/pkg5_publisher.py | 9 +++- .../modules/extras/packaging/os/pkgin.py | 32 +++++++++---- .../modules/extras/packaging/os/pkgng.py | 12 +++-- .../modules/extras/packaging/os/pkgutil.py | 9 +++- .../modules/extras/packaging/os/portage.py | 34 +++++++++---- .../extras/packaging/os/portinstall.py | 12 +++-- .../modules/extras/packaging/os/slackpkg.py | 13 +++-- .../modules/extras/packaging/os/svr4pkg.py | 26 ++++++++-- .../modules/extras/packaging/os/swdepot.py | 16 +++++-- .../modules/extras/packaging/os/urpmi.py | 20 ++++++-- .../extras/packaging/os/yum_repository.py | 1 + .../modules/extras/packaging/os/zypper.py | 44 +++++++++++++---- .../extras/packaging/os/zypper_repository.py | 27 ++++++++--- 34 files changed, 589 insertions(+), 186 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/dpkg_selections.py b/lib/ansible/modules/extras/packaging/dpkg_selections.py index fa0f73a713..81dd849e59 100644 --- a/lib/ansible/modules/extras/packaging/dpkg_selections.py +++ b/lib/ansible/modules/extras/packaging/dpkg_selections.py @@ -39,7 +39,9 @@ notes: ''' EXAMPLES = ''' # Prevent python from being upgraded. -- dpkg_selections: name=python selection=hold +- dpkg_selections: + name: python + selection: hold ''' def main(): diff --git a/lib/ansible/modules/extras/packaging/elasticsearch_plugin.py b/lib/ansible/modules/extras/packaging/elasticsearch_plugin.py index 4d0b7964c3..5ca77f1bc7 100644 --- a/lib/ansible/modules/extras/packaging/elasticsearch_plugin.py +++ b/lib/ansible/modules/extras/packaging/elasticsearch_plugin.py @@ -83,13 +83,20 @@ options: EXAMPLES = ''' # Install Elasticsearch head plugin -- elasticsearch_plugin: state=present name="mobz/elasticsearch-head" +- elasticsearch_plugin: + state: present + name: mobz/elasticsearch-head # Install specific version of a plugin -- elasticsearch_plugin: state=present name="com.github.kzwang/elasticsearch-image" version="1.2.0" +- elasticsearch_plugin: + state: present + name: com.github.kzwang/elasticsearch-image + version: '1.2.0' # Uninstall Elasticsearch head plugin -- elasticsearch_plugin: state=absent name="mobz/elasticsearch-head" +- elasticsearch_plugin: + state: absent + name: mobz/elasticsearch-head ''' PACKAGE_STATE_MAP = dict( diff --git a/lib/ansible/modules/extras/packaging/kibana_plugin.py b/lib/ansible/modules/extras/packaging/kibana_plugin.py index f0ffcd9ddf..e877d756b0 100644 --- a/lib/ansible/modules/extras/packaging/kibana_plugin.py +++ b/lib/ansible/modules/extras/packaging/kibana_plugin.py @@ -79,13 +79,20 @@ options: EXAMPLES = ''' # Install Elasticsearch head plugin -- kibana_plugin: state=present name="elasticsearch/marvel" +- kibana_plugin: + state: present + name=: elasticsearch/marvel # Install specific version of a plugin -- kibana_plugin: state=present name="elasticsearch/marvel" version="2.3.3" +- kibana_plugin: + state: present + name: elasticsearch/marvel + version: '2.3.3' # Uninstall Elasticsearch head plugin -- kibana_plugin: state=absent name="elasticsearch/marvel" +- kibana_plugin: + state: absent + name: elasticsearch/marvel ''' RETURN = ''' diff --git a/lib/ansible/modules/extras/packaging/language/bower.py b/lib/ansible/modules/extras/packaging/language/bower.py index 2b58b1ce1f..1627741d5a 100644 --- a/lib/ansible/modules/extras/packaging/language/bower.py +++ b/lib/ansible/modules/extras/packaging/language/bower.py @@ -67,24 +67,37 @@ options: ''' EXAMPLES = ''' -description: Install "bootstrap" bower package. -- bower: name=bootstrap +- name: Install "bootstrap" bower package. + bower: + name: bootstrap -description: Install "bootstrap" bower package on version 3.1.1. -- bower: name=bootstrap version=3.1.1 +- name: Install "bootstrap" bower package on version 3.1.1. + bower: + name: bootstrap + version: '3.1.1' -description: Remove the "bootstrap" bower package. -- bower: name=bootstrap state=absent +- name: Remove the "bootstrap" bower package. + bower: + name: bootstrap + state: absent -description: Install packages based on bower.json. -- bower: path=/app/location +- name: Install packages based on bower.json. + bower: + path: /app/location -description: Update packages based on bower.json to their latest version. -- bower: path=/app/location state=latest +- name: Update packages based on bower.json to their latest version. + bower: + path: /app/location + state: latest -description: install bower locally and run from there -- npm: path=/app/location name=bower global=no -- bower: path=/app/location relative_execpath=node_modules/.bin +# install bower locally and run from there +- npm: + path: /app/location + name: bower + global: no +- bower: + path: /app/location + relative_execpath: node_modules/.bin ''' diff --git a/lib/ansible/modules/extras/packaging/language/bundler.py b/lib/ansible/modules/extras/packaging/language/bundler.py index 152b51810a..fc647862fd 100644 --- a/lib/ansible/modules/extras/packaging/language/bundler.py +++ b/lib/ansible/modules/extras/packaging/language/bundler.py @@ -112,19 +112,29 @@ author: "Tim Hoiberg (@thoiberg)" EXAMPLES=''' # Installs gems from a Gemfile in the current directory -- bundler: state=present executable=~/.rvm/gems/2.1.5/bin/bundle +- bundler: + state: present + executable: ~/.rvm/gems/2.1.5/bin/bundle # Excludes the production group from installing -- bundler: state=present exclude_groups=production +- bundler: + state: present + exclude_groups: production # Only install gems from the default and production groups -- bundler: state=present deployment_mode=yes +- bundler: + state: present + deployment_mode: yes # Installs gems using a Gemfile in another directory -- bundler: state=present gemfile=../rails_project/Gemfile +- bundler: + state: present + gemfile: ../rails_project/Gemfile # Updates Gemfile in another directory -- bundler: state=latest chdir=~/rails_project +- bundler: + state: latest + chdir: ~/rails_project ''' diff --git a/lib/ansible/modules/extras/packaging/language/composer.py b/lib/ansible/modules/extras/packaging/language/composer.py index 4c5f8518be..9ff393b25b 100644 --- a/lib/ansible/modules/extras/packaging/language/composer.py +++ b/lib/ansible/modules/extras/packaging/language/composer.py @@ -108,19 +108,21 @@ notes: EXAMPLES = ''' # Downloads and installs all the libs and dependencies outlined in the /path/to/project/composer.lock -- composer: command=install working_dir=/path/to/project +- composer: + command: install + working_dir: /path/to/project - composer: - command: "require" - arguments: "my/package" - working_dir: "/path/to/project" + command: require + arguments: my/package + working_dir: /path/to/project # Clone project and install with all dependencies - composer: - command: "create-project" - arguments: "package/package /path/to/project ~1.0" - working_dir: "/path/to/project" - prefer_dist: "yes" + command: create-project + arguments: package/package /path/to/project ~1.0 + working_dir: /path/to/project + prefer_dist: yes ''' import os diff --git a/lib/ansible/modules/extras/packaging/language/cpanm.py b/lib/ansible/modules/extras/packaging/language/cpanm.py index 790a493915..26566c6dbf 100644 --- a/lib/ansible/modules/extras/packaging/language/cpanm.py +++ b/lib/ansible/modules/extras/packaging/language/cpanm.py @@ -91,29 +91,43 @@ author: "Franck Cuny (@franckcuny)" EXAMPLES = ''' # install Dancer perl package -- cpanm: name=Dancer +- cpanm: + name: Dancer # install version 0.99_05 of the Plack perl package -- cpanm: name=MIYAGAWA/Plack-0.99_05.tar.gz +- cpanm: + name: MIYAGAWA/Plack-0.99_05.tar.gz # install Dancer into the specified locallib -- cpanm: name=Dancer locallib=/srv/webapps/my_app/extlib +- cpanm: + name: Dancer + locallib: /srv/webapps/my_app/extlib # install perl dependencies from local directory -- cpanm: from_path=/srv/webapps/my_app/src/ +- cpanm: + from_path: /srv/webapps/my_app/src/ # install Dancer perl package without running the unit tests in indicated locallib -- cpanm: name=Dancer notest=True locallib=/srv/webapps/my_app/extlib +- cpanm: + name: Dancer + notest: True + locallib: /srv/webapps/my_app/extlib # install Dancer perl package from a specific mirror -- cpanm: name=Dancer mirror=http://cpan.cpantesters.org/ +- cpanm: + name: Dancer + mirror: 'http://cpan.cpantesters.org/' # install Dancer perl package into the system root path -- cpanm: name=Dancer system_lib=yes +- cpanm: + name: Dancer + system_lib: yes # install Dancer if it's not already installed # OR the installed version is older than version 1.0 -- cpanm: name=Dancer version=1.0 +- cpanm: + name: Dancer + version: '1.0' ''' def _is_package_installed(module, name, locallib, cpanm, version): diff --git a/lib/ansible/modules/extras/packaging/language/maven_artifact.py b/lib/ansible/modules/extras/packaging/language/maven_artifact.py index 5c0e88ac72..3e7fddbd0a 100644 --- a/lib/ansible/modules/extras/packaging/language/maven_artifact.py +++ b/lib/ansible/modules/extras/packaging/language/maven_artifact.py @@ -119,16 +119,34 @@ options: EXAMPLES = ''' # Download the latest version of the JUnit framework artifact from Maven Central -- maven_artifact: group_id=junit artifact_id=junit dest=/tmp/junit-latest.jar +- maven_artifact: + group_id: junit + artifact_id: junit + dest: /tmp/junit-latest.jar # Download JUnit 4.11 from Maven Central -- maven_artifact: group_id=junit artifact_id=junit version=4.11 dest=/tmp/junit-4.11.jar +- maven_artifact: + group_id: junit + artifact_id: junit + version: 4.11 + dest: /tmp/junit-4.11.jar # Download an artifact from a private repository requiring authentication -- maven_artifact: group_id=com.company artifact_id=library-name repository_url=https://repo.company.com/maven username=user password=pass dest=/tmp/library-name-latest.jar +- maven_artifact: + group_id: com.company + artifact_id: library-name + repository_url: 'https://repo.company.com/maven' + username: user + password: pass + dest: /tmp/library-name-latest.jar # Download a WAR File to the Tomcat webapps directory to be deployed -- maven_artifact: group_id=com.company artifact_id=web-app extension=war repository_url=https://repo.company.com/maven dest=/var/lib/tomcat7/webapps/web-app.war +- maven_artifact: + group_id: com.company + artifact_id: web-app + extension: war + repository_url: 'https://repo.company.com/maven' + dest: /var/lib/tomcat7/webapps/web-app.war ''' class Artifact(object): diff --git a/lib/ansible/modules/extras/packaging/language/npm.py b/lib/ansible/modules/extras/packaging/language/npm.py index e15bbea903..58e29dc86e 100644 --- a/lib/ansible/modules/extras/packaging/language/npm.py +++ b/lib/ansible/modules/extras/packaging/language/npm.py @@ -78,28 +78,46 @@ options: EXAMPLES = ''' description: Install "coffee-script" node.js package. -- npm: name=coffee-script path=/app/location +- npm: + name: coffee-script + path: /app/location description: Install "coffee-script" node.js package on version 1.6.1. -- npm: name=coffee-script version=1.6.1 path=/app/location +- npm: + name: coffee-script + version: '1.6.1' + path: /app/location description: Install "coffee-script" node.js package globally. -- npm: name=coffee-script global=yes +- npm: + name: coffee-script + global: yes description: Remove the globally package "coffee-script". -- npm: name=coffee-script global=yes state=absent +- npm: + name: coffee-script + global: yes + state: absent description: Install "coffee-script" node.js package from custom registry. -- npm: name=coffee-script registry=http://registry.mysite.com +- npm: + name: coffee-script + registry: 'http://registry.mysite.com' description: Install packages based on package.json. -- npm: path=/app/location +- npm: + path: /app/location description: Update packages based on package.json to their latest version. -- npm: path=/app/location state=latest +- npm: + path: /app/location + state: latest description: Install packages based on package.json using the npm installed with nvm v0.10.1. -- npm: path=/app/location executable=/opt/nvm/v0.10.1/bin/npm state=present +- npm: + path: /app/location + executable: /opt/nvm/v0.10.1/bin/npm + state: present ''' import os diff --git a/lib/ansible/modules/extras/packaging/language/pear.py b/lib/ansible/modules/extras/packaging/language/pear.py index 5762f9c815..ae513baf14 100644 --- a/lib/ansible/modules/extras/packaging/language/pear.py +++ b/lib/ansible/modules/extras/packaging/language/pear.py @@ -45,16 +45,24 @@ options: EXAMPLES = ''' # Install pear package -- pear: name=Net_URL2 state=present +- pear: + name: Net_URL2 + state: present # Install pecl package -- pear: name=pecl/json_post state=present +- pear: + name: pecl/json_post + state: present # Upgrade package -- pear: name=Net_URL2 state=latest +- pear: + name: Net_URL2 + state: latest # Remove packages -- pear: name=Net_URL2,pecl/json_post state=absent +- pear: + name: Net_URL2,pecl/json_post + state: absent ''' import os diff --git a/lib/ansible/modules/extras/packaging/os/apk.py b/lib/ansible/modules/extras/packaging/os/apk.py index 911e50e094..898b69a304 100644 --- a/lib/ansible/modules/extras/packaging/os/apk.py +++ b/lib/ansible/modules/extras/packaging/os/apk.py @@ -58,34 +58,54 @@ notes: EXAMPLES = ''' # Update repositories and install "foo" package -- apk: name=foo update_cache=yes +- apk: + name: foo + update_cache: yes # Update repositories and install "foo" and "bar" packages -- apk: name=foo,bar update_cache=yes +- apk: + name: foo,bar + update_cache: yes # Remove "foo" package -- apk: name=foo state=absent +- apk: + name: foo + state: absent # Remove "foo" and "bar" packages -- apk: name=foo,bar state=absent +- apk: + name: foo,bar + state: absent # Install the package "foo" -- apk: name=foo state=present +- apk: + name: foo + state: present # Install the packages "foo" and "bar" -- apk: name=foo,bar state=present +- apk: + name: foo,bar + state: present # Update repositories and update package "foo" to latest version -- apk: name=foo state=latest update_cache=yes +- apk: + name: foo + state: latest + update_cache: yes # Update repositories and update packages "foo" and "bar" to latest versions -- apk: name=foo,bar state=latest update_cache=yes +- apk: + name: foo,bar + state: latest + update_cache: yes # Update all installed packages to the latest versions -- apk: upgrade=yes +- apk: + upgrade: yes # Update repositories as a separate step -- apk: update_cache=yes +- apk: + update_cache: yes ''' import os diff --git a/lib/ansible/modules/extras/packaging/os/dnf.py b/lib/ansible/modules/extras/packaging/os/dnf.py index 74b83ae9d1..56af89f544 100644 --- a/lib/ansible/modules/extras/packaging/os/dnf.py +++ b/lib/ansible/modules/extras/packaging/os/dnf.py @@ -101,26 +101,40 @@ author: EXAMPLES = ''' - name: install the latest version of Apache - dnf: name=httpd state=latest + dnf: + name: httpd + state: latest - name: remove the Apache package - dnf: name=httpd state=absent + dnf: + name: httpd + state: absent - name: install the latest version of Apache from the testing repo - dnf: name=httpd enablerepo=testing state=present + dnf: + name: httpd + enablerepo: testing + state: present - name: upgrade all packages - dnf: name=* state=latest + dnf: + name: * + state: latest - name: install the nginx rpm from a remote repo - dnf: name=http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm state=present + dnf: + name: 'http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm' + state: present - name: install nginx rpm from a local file - dnf: name=/usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm state=present + dnf: + name: /usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm + state: present - name: install the 'Development tools' package group - dnf: name="@Development tools" state=present - + dnf: + name: '@Development tools' + state: present ''' import os diff --git a/lib/ansible/modules/extras/packaging/os/homebrew.py b/lib/ansible/modules/extras/packaging/os/homebrew.py index d48491d15e..be67b6b918 100755 --- a/lib/ansible/modules/extras/packaging/os/homebrew.py +++ b/lib/ansible/modules/extras/packaging/os/homebrew.py @@ -76,26 +76,54 @@ notes: [] ''' EXAMPLES = ''' # Install formula foo with 'brew' in default path (C(/usr/local/bin)) -- homebrew: name=foo state=present +- homebrew: + name: foo + state: present # Install formula foo with 'brew' in alternate path C(/my/other/location/bin) -- homebrew: name=foo path=/my/other/location/bin state=present +- homebrew: + name: foo + path: /my/other/location/bin + state: present # Update homebrew first and install formula foo with 'brew' in default path -- homebrew: name=foo state=present update_homebrew=yes +- homebrew: + name: foo + state: present + update_homebrew: yes # Update homebrew first and upgrade formula foo to latest available with 'brew' in default path -- homebrew: name=foo state=latest update_homebrew=yes +- homebrew: + name: foo + state: latest + update_homebrew: yes # Update homebrew and upgrade all packages -- homebrew: update_homebrew=yes upgrade_all=yes +- homebrew: + update_homebrew: yes + upgrade_all: yes # Miscellaneous other examples -- homebrew: name=foo state=head -- homebrew: name=foo state=linked -- homebrew: name=foo state=absent -- homebrew: name=foo,bar state=absent -- homebrew: name=foo state=present install_options=with-baz,enable-debug +- homebrew: + name: foo + state: head + +- homebrew: + name: foo + state: linked + +- homebrew: + name: foo + state: absent + +- homebrew: + name: foo,bar + state: absent + +- homebrew: + name: foo + state: present + install_options: with-baz,enable-debug ''' import os.path diff --git a/lib/ansible/modules/extras/packaging/os/homebrew_cask.py b/lib/ansible/modules/extras/packaging/os/homebrew_cask.py index 2d1722398e..fdfa3f0cdb 100755 --- a/lib/ansible/modules/extras/packaging/os/homebrew_cask.py +++ b/lib/ansible/modules/extras/packaging/os/homebrew_cask.py @@ -65,11 +65,28 @@ options: version_added: "2.2" ''' EXAMPLES = ''' -- homebrew_cask: name=alfred state=present -- homebrew_cask: name=alfred state=absent -- homebrew_cask: name=alfred state=present install_options="appdir=/Applications" -- homebrew_cask: name=alfred state=present install_options="debug,appdir=/Applications" -- homebrew_cask: name=alfred state=absent install_options="force" +- homebrew_cask: + name: alfred + state: present + +- homebrew_cask: + name: alfred + state: absent + +- homebrew_cask: + name: alfred + state: present + install_options: 'appdir=/Applications' + +- homebrew_cask: + name: alfred + state: present + install_options: 'debug,appdir=/Applications' + +- homebrew_cask: + name: alfred + state: absent + install_options: force ''' import os.path diff --git a/lib/ansible/modules/extras/packaging/os/homebrew_tap.py b/lib/ansible/modules/extras/packaging/os/homebrew_tap.py index 9264db8775..2a981deaeb 100644 --- a/lib/ansible/modules/extras/packaging/os/homebrew_tap.py +++ b/lib/ansible/modules/extras/packaging/os/homebrew_tap.py @@ -59,10 +59,20 @@ requirements: [ homebrew ] ''' EXAMPLES = ''' -homebrew_tap: name=homebrew/dupes -homebrew_tap: name=homebrew/dupes state=absent -homebrew_tap: name=homebrew/dupes,homebrew/science state=present -homebrew_tap: name=telemachus/brew url=https://bitbucket.org/telemachus/brew +- homebrew_tap: + name: homebrew/dupes + +- homebrew_tap: + name: homebrew/dupes + state: absent + +- homebrew_tap: + name: homebrew/dupes,homebrew/science + state: present + +- homebrew_tap: + name: telemachus/brew + url: 'https://bitbucket.org/telemachus/brew' ''' diff --git a/lib/ansible/modules/extras/packaging/os/layman.py b/lib/ansible/modules/extras/packaging/os/layman.py index ac6acd12d4..f18d0eaa0a 100644 --- a/lib/ansible/modules/extras/packaging/os/layman.py +++ b/lib/ansible/modules/extras/packaging/os/layman.py @@ -64,19 +64,29 @@ options: EXAMPLES = ''' # Install the overlay 'mozilla' which is on the central overlays list. -- layman: name=mozilla +- layman: + name: mozilla # Install the overlay 'cvut' from the specified alternative list. -- layman: name=cvut list_url=http://raw.github.com/cvut/gentoo-overlay/master/overlay.xml +- layman: + name: cvut + list_url: 'http://raw.github.com/cvut/gentoo-overlay/master/overlay.xml' # Update (sync) the overlay 'cvut', or install if not installed yet. -- layman: name=cvut list_url=http://raw.github.com/cvut/gentoo-overlay/master/overlay.xml state=updated +- layman: + name: cvut + list_url: 'http://raw.github.com/cvut/gentoo-overlay/master/overlay.xml' + state: updated # Update (sync) all of the installed overlays. -- layman: name=ALL state=updated +- layman: + name: ALL + state: updated # Uninstall the overlay 'cvut'. -- layman: name=cvut state=absent +- layman: + name: cvut + state: absent ''' USERAGENT = 'ansible-httpget' diff --git a/lib/ansible/modules/extras/packaging/os/macports.py b/lib/ansible/modules/extras/packaging/os/macports.py index ae7010b1cb..19121f4a85 100644 --- a/lib/ansible/modules/extras/packaging/os/macports.py +++ b/lib/ansible/modules/extras/packaging/os/macports.py @@ -46,11 +46,26 @@ options: notes: [] ''' EXAMPLES = ''' -- macports: name=foo state=present -- macports: name=foo state=present update_cache=yes -- macports: name=foo state=absent -- macports: name=foo state=active -- macports: name=foo state=inactive +- macports: + name: foo + state: present + +- macports: + name: foo + state: present + update_cache: yes + +- macports: + name: foo + state: absent + +- macports: + name: foo + state: active + +- macports: + name: foo + state: inactive ''' import pipes diff --git a/lib/ansible/modules/extras/packaging/os/openbsd_pkg.py b/lib/ansible/modules/extras/packaging/os/openbsd_pkg.py index 67583cdf36..e68ef18989 100644 --- a/lib/ansible/modules/extras/packaging/os/openbsd_pkg.py +++ b/lib/ansible/modules/extras/packaging/os/openbsd_pkg.py @@ -68,28 +68,45 @@ options: EXAMPLES = ''' # Make sure nmap is installed -- openbsd_pkg: name=nmap state=present +- openbsd_pkg: + name: nmap + state: present # Make sure nmap is the latest version -- openbsd_pkg: name=nmap state=latest +- openbsd_pkg: + name: nmap + state: latest # Make sure nmap is not installed -- openbsd_pkg: name=nmap state=absent +- openbsd_pkg: + name: nmap + state: absent # Make sure nmap is installed, build it from source if it is not -- openbsd_pkg: name=nmap state=present build=yes +- openbsd_pkg: + name: nmap + state: present + build: yes # Specify a pkg flavour with '--' -- openbsd_pkg: name=vim--no_x11 state=present +- openbsd_pkg: + name: vim--no_x11 + state: present # Specify the default flavour to avoid ambiguity errors -- openbsd_pkg: name=vim-- state=present +- openbsd_pkg: + name: vim-- + state: present # Specify a package branch (requires at least OpenBSD 6.0) -- openbsd_pkg: name=python%3.5 state=present +- openbsd_pkg: + name: python%3.5 + state: present # Update all packages on the system -- openbsd_pkg: name=* state=latest +- openbsd_pkg: + name: * + state: latest ''' # Function used for executing commands. diff --git a/lib/ansible/modules/extras/packaging/os/opkg.py b/lib/ansible/modules/extras/packaging/os/opkg.py index 9ac8f99b8c..1d74020240 100644 --- a/lib/ansible/modules/extras/packaging/os/opkg.py +++ b/lib/ansible/modules/extras/packaging/os/opkg.py @@ -52,11 +52,27 @@ options: notes: [] ''' EXAMPLES = ''' -- opkg: name=foo state=present -- opkg: name=foo state=present update_cache=yes -- opkg: name=foo state=absent -- opkg: name=foo,bar state=absent -- opkg: name=foo state=present force=overwrite +- opkg: + name: foo + state: present + +- opkg: + name: foo + state: present + update_cache: yes + +- opkg: + name: foo + state: absent + +- opkg: + name: foo,bar + state: absent + +- opkg: + name: foo + state: present + force: overwrite ''' import pipes diff --git a/lib/ansible/modules/extras/packaging/os/pacman.py b/lib/ansible/modules/extras/packaging/os/pacman.py index 74c474ad92..c27a67c9e7 100644 --- a/lib/ansible/modules/extras/packaging/os/pacman.py +++ b/lib/ansible/modules/extras/packaging/os/pacman.py @@ -89,28 +89,45 @@ options: EXAMPLES = ''' # Install package foo -- pacman: name=foo state=present +- pacman: + name: foo + state: present # Upgrade package foo -- pacman: name=foo state=latest update_cache=yes +- pacman: + name: foo + state: latest + update_cache: yes # Remove packages foo and bar -- pacman: name=foo,bar state=absent +- pacman: + name: foo,bar + state: absent # Recursively remove package baz -- pacman: name=baz state=absent recurse=yes +- pacman: + name: baz + state: absent + recurse: yes # Run the equivalent of "pacman -Sy" as a separate step -- pacman: update_cache=yes +- pacman: + update_cache: yes # Run the equivalent of "pacman -Su" as a separate step -- pacman: upgrade=yes +- pacman: + upgrade: yes # Run the equivalent of "pacman -Syu" as a separate step -- pacman: update_cache=yes upgrade=yes +- pacman: + update_cache: yes + upgrade: yes # Run the equivalent of "pacman -Rdd", force remove package baz -- pacman: name=baz state=absent force=yes +- pacman: + name: baz + state: absent + force: yes ''' import shlex diff --git a/lib/ansible/modules/extras/packaging/os/pkg5.py b/lib/ansible/modules/extras/packaging/os/pkg5.py index c74b0fa5d8..7f476e4bc0 100644 --- a/lib/ansible/modules/extras/packaging/os/pkg5.py +++ b/lib/ansible/modules/extras/packaging/os/pkg5.py @@ -48,10 +48,13 @@ options: ''' EXAMPLES = ''' # Install Vim: -- pkg5: name=editor/vim +- pkg5: + name: editor/vim # Remove finger daemon: -- pkg5: name=service/network/finger state=absent +- pkg5: + name: service/network/finger + state: absent # Install several packages at once: - pkg5: diff --git a/lib/ansible/modules/extras/packaging/os/pkg5_publisher.py b/lib/ansible/modules/extras/packaging/os/pkg5_publisher.py index 0dd3b5112d..a540e36afb 100644 --- a/lib/ansible/modules/extras/packaging/os/pkg5_publisher.py +++ b/lib/ansible/modules/extras/packaging/os/pkg5_publisher.py @@ -65,10 +65,15 @@ options: ''' EXAMPLES = ''' # Fetch packages for the solaris publisher direct from Oracle: -- pkg5_publisher: name=solaris sticky=true origin=https://pkg.oracle.com/solaris/support/ +- pkg5_publisher: + name: solaris + sticky: true + origin: https://pkg.oracle.com/solaris/support/ # Configure a publisher for locally-produced packages: -- pkg5_publisher: name=site origin=https://pkg.example.com/site/ +- pkg5_publisher: + name: site + origin: 'https://pkg.example.com/site/' ''' def main(): diff --git a/lib/ansible/modules/extras/packaging/os/pkgin.py b/lib/ansible/modules/extras/packaging/os/pkgin.py index 055891ebe0..19f9a157b3 100755 --- a/lib/ansible/modules/extras/packaging/os/pkgin.py +++ b/lib/ansible/modules/extras/packaging/os/pkgin.py @@ -91,31 +91,45 @@ options: EXAMPLES = ''' # install package foo -- pkgin: name=foo state=present +- pkgin: + name: foo + state: present # Update database and install "foo" package -- pkgin: name=foo update_cache=yes +- pkgin: + name: foo + update_cache: yes # remove package foo -- pkgin: name=foo state=absent +- pkgin: + name: foo + state: absent # remove packages foo and bar -- pkgin: name=foo,bar state=absent +- pkgin: + name: foo,bar + state: absent # Update repositories as a separate step -- pkgin: update_cache=yes +- pkgin: + update_cache: yes # Upgrade main packages (equivalent to C(pkgin upgrade)) -- pkgin: upgrade=yes +- pkgin: + upgrade: yes # Upgrade all packages (equivalent to C(pkgin full-upgrade)) -- pkgin: full_upgrade=yes +- pkgin: + full_upgrade: yes # Force-upgrade all packages (equivalent to C(pkgin -F full-upgrade)) -- pkgin: full_upgrade=yes force=yes +- pkgin: + full_upgrade: yes + force: yes # clean packages cache (equivalent to C(pkgin clean)) -- pkgin: clean=yes +- pkgin: + clean: yes ''' diff --git a/lib/ansible/modules/extras/packaging/os/pkgng.py b/lib/ansible/modules/extras/packaging/os/pkgng.py index eb0278cd9b..d583e59c0c 100644 --- a/lib/ansible/modules/extras/packaging/os/pkgng.py +++ b/lib/ansible/modules/extras/packaging/os/pkgng.py @@ -89,13 +89,19 @@ notes: EXAMPLES = ''' # Install package foo -- pkgng: name=foo state=present +- pkgng: + name: foo + state: present # Annotate package foo and bar -- pkgng: name=foo,bar annotation=+test1=baz,-test2,:test3=foobar +- pkgng: + name: foo,bar + annotation: '+test1=baz,-test2,:test3=foobar' # Remove packages foo and bar -- pkgng: name=foo,bar state=absent +- pkgng: + name: foo,bar + state: absent ''' diff --git a/lib/ansible/modules/extras/packaging/os/pkgutil.py b/lib/ansible/modules/extras/packaging/os/pkgutil.py index 35ccb4e190..8495a19b24 100644 --- a/lib/ansible/modules/extras/packaging/os/pkgutil.py +++ b/lib/ansible/modules/extras/packaging/os/pkgutil.py @@ -60,10 +60,15 @@ options: EXAMPLES = ''' # Install a package -pkgutil: name=CSWcommon state=present +- pkgutil: + name: CSWcommon + state: present # Install a package from a specific repository -pkgutil: name=CSWnrpe site='ftp://myinternal.repo/opencsw/kiel state=latest' +- pkgutil: + name: CSWnrpe + site: 'ftp://myinternal.repo/opencsw/kiel' + state: latest ''' import os diff --git a/lib/ansible/modules/extras/packaging/os/portage.py b/lib/ansible/modules/extras/packaging/os/portage.py index 2880902fb9..0f3731968b 100644 --- a/lib/ansible/modules/extras/packaging/os/portage.py +++ b/lib/ansible/modules/extras/packaging/os/portage.py @@ -183,28 +183,46 @@ notes: [] EXAMPLES = ''' # Make sure package foo is installed -- portage: package=foo state=present +- portage: + package: foo + state: present # Make sure package foo is not installed -- portage: package=foo state=absent +- portage: + package: foo + state: absent # Update package foo to the "best" version -- portage: package=foo update=yes +- portage: + package: foo + update: yes # Install package foo using PORTAGE_BINHOST setup -- portage: package=foo getbinpkg=yes +- portage: + package: foo + getbinpkg: yes # Re-install world from binary packages only and do not allow any compiling -- portage: package=@world usepkgonly=yes +- portage: + package: @world + usepkgonly: yes # Sync repositories and update world -- portage: package=@world update=yes deep=yes sync=yes +- portage: + package: @world + update: yes + deep: yes + sync: yes # Remove unneeded packages -- portage: depclean=yes +- portage: + depclean: yes # Remove package foo if it is not explicitly needed -- portage: package=foo state=absent depclean=yes +- portage: + package: foo + state: absent + depclean: yes ''' diff --git a/lib/ansible/modules/extras/packaging/os/portinstall.py b/lib/ansible/modules/extras/packaging/os/portinstall.py index a5d0e51097..44f21efb7c 100644 --- a/lib/ansible/modules/extras/packaging/os/portinstall.py +++ b/lib/ansible/modules/extras/packaging/os/portinstall.py @@ -48,13 +48,19 @@ author: "berenddeboer (@berenddeboer)" EXAMPLES = ''' # Install package foo -- portinstall: name=foo state=present +- portinstall: + name: foo + state: present # Install package security/cyrus-sasl2-saslauthd -- portinstall: name=security/cyrus-sasl2-saslauthd state=present +- portinstall: + name: security/cyrus-sasl2-saslauthd + state: present # Remove packages foo and bar -- portinstall: name=foo,bar state=absent +- portinstall: + name: foo,bar + state: absent ''' diff --git a/lib/ansible/modules/extras/packaging/os/slackpkg.py b/lib/ansible/modules/extras/packaging/os/slackpkg.py index fe7dacda9d..0581fbd191 100644 --- a/lib/ansible/modules/extras/packaging/os/slackpkg.py +++ b/lib/ansible/modules/extras/packaging/os/slackpkg.py @@ -56,14 +56,19 @@ requirements: [ "Slackware" >= 12.2 ] EXAMPLES = ''' # Install package foo -- slackpkg: name=foo state=present +- slackpkg: + name: foo + state: present # Remove packages foo and bar -- slackpkg: name=foo,bar state=absent +- slackpkg: + name: foo,bar + state: absent # Make sure that it is the most updated package -- slackpkg: name=foo state=latest - +- slackpkg: + name: foo + state: latest ''' diff --git a/lib/ansible/modules/extras/packaging/os/svr4pkg.py b/lib/ansible/modules/extras/packaging/os/svr4pkg.py index 149238171b..c31a100464 100644 --- a/lib/ansible/modules/extras/packaging/os/svr4pkg.py +++ b/lib/ansible/modules/extras/packaging/os/svr4pkg.py @@ -75,19 +75,35 @@ options: EXAMPLES = ''' # Install a package from an already copied file -- svr4pkg: name=CSWcommon src=/tmp/cswpkgs.pkg state=present +- svr4pkg: + name: CSWcommon + src: /tmp/cswpkgs.pkg + state: present # Install a package directly from an http site -- svr4pkg: name=CSWpkgutil src=http://get.opencsw.org/now state=present zone=current +- svr4pkg: + name: CSWpkgutil + src: 'http://get.opencsw.org/now' + state: present + zone: current # Install a package with a response file -- svr4pkg: name=CSWggrep src=/tmp/third-party.pkg response_file=/tmp/ggrep.response state=present +- svr4pkg: + name: CSWggrep + src: /tmp/third-party.pkg + response_file: /tmp/ggrep.response + state: present # Ensure that a package is not installed. -- svr4pkg: name=SUNWgnome-sound-recorder state=absent +- svr4pkg: + name: SUNWgnome-sound-recorder + state: absent # Ensure that a category is not installed. -- svr4pkg: name=FIREFOX state=absent category=true +- svr4pkg: + name: FIREFOX + state: absent + category: true ''' diff --git a/lib/ansible/modules/extras/packaging/os/swdepot.py b/lib/ansible/modules/extras/packaging/os/swdepot.py index b14af74205..8c7652af96 100644 --- a/lib/ansible/modules/extras/packaging/os/swdepot.py +++ b/lib/ansible/modules/extras/packaging/os/swdepot.py @@ -58,9 +58,19 @@ options: ''' EXAMPLES = ''' -- swdepot: name=unzip-6.0 state=installed depot=repository:/path -- swdepot: name=unzip state=latest depot=repository:/path -- swdepot: name=unzip state=absent +- swdepot: + name: unzip-6.0 + state: installed + depot: 'repository:/path' + +- swdepot: + name: unzip + state: latest + depot: 'repository:/path' + +- swdepot: + name: unzip + state: absent ''' def compare_package(version1, version2): diff --git a/lib/ansible/modules/extras/packaging/os/urpmi.py b/lib/ansible/modules/extras/packaging/os/urpmi.py index 0b9ec92931..47d7c1f684 100644 --- a/lib/ansible/modules/extras/packaging/os/urpmi.py +++ b/lib/ansible/modules/extras/packaging/os/urpmi.py @@ -63,13 +63,25 @@ notes: [] EXAMPLES = ''' # install package foo -- urpmi: pkg=foo state=present +- urpmi: + pkg: foo + state: present + # remove package foo -- urpmi: pkg=foo state=absent +- urpmi: + pkg: foo + state: absent + # description: remove packages foo and bar -- urpmi: pkg=foo,bar state=absent +- urpmi: + pkg: foo,bar + state: absent + # description: update the package database (urpmi.update -a -q) and install bar (bar will be the updated if a newer version exists) -- urpmi: name=bar, state=present, update_cache=yes +- urpmi: + name: bar + state: present + update_cache: yes ''' diff --git a/lib/ansible/modules/extras/packaging/os/yum_repository.py b/lib/ansible/modules/extras/packaging/os/yum_repository.py index 7848da1fb1..e1355baa32 100644 --- a/lib/ansible/modules/extras/packaging/os/yum_repository.py +++ b/lib/ansible/modules/extras/packaging/os/yum_repository.py @@ -410,6 +410,7 @@ EXAMPLES = ''' file: external_repos baseurl: http://download.fedoraproject.org/pub/epel/$releasever/$basearch/ gpgcheck: no + - name: Add multiple repositories into the same file (2/2) yum_repository: name: rpmforge diff --git a/lib/ansible/modules/extras/packaging/os/zypper.py b/lib/ansible/modules/extras/packaging/os/zypper.py index 7b385e792e..c91528b219 100644 --- a/lib/ansible/modules/extras/packaging/os/zypper.py +++ b/lib/ansible/modules/extras/packaging/os/zypper.py @@ -113,34 +113,58 @@ requirements: EXAMPLES = ''' # Install "nmap" -- zypper: name=nmap state=present +- zypper: + name: nmap + state: present # Install apache2 with recommended packages -- zypper: name=apache2 state=present disable_recommends=no +- zypper: + name: apache2 + state: present + disable_recommends: no # Apply a given patch -- zypper: name=openSUSE-2016-128 state=present type=patch +- zypper: + name: openSUSE-2016-128 + state: present + type: patch # Remove the "nmap" package -- zypper: name=nmap state=absent +- zypper: + name: nmap + state: absent # Install the nginx rpm from a remote repo -- zypper: name=http://nginx.org/packages/sles/12/x86_64/RPMS/nginx-1.8.0-1.sles12.ngx.x86_64.rpm state=present +- zypper: + name: 'http://nginx.org/packages/sles/12/x86_64/RPMS/nginx-1.8.0-1.sles12.ngx.x86_64.rpm' + state: present # Install local rpm file -- zypper: name=/tmp/fancy-software.rpm state=present +- zypper: + name: /tmp/fancy-software.rpm + state: present # Update all packages -- zypper: name=* state=latest +- zypper: + name: * + state: latest # Apply all available patches -- zypper: name=* state=latest type=patch +- zypper: + name: * + state: latest + type: patch # Refresh repositories and update package "openssl" -- zypper: name=openssl state=present update_cache=yes +- zypper: + name: openssl + state: present + update_cache: yes # Install specific version (possible comparisons: <, >, <=, >=, =) -- zypper: name=docker>=1.10 state=installed +- zypper: + name: 'docker>=1.10' + state: installed ''' diff --git a/lib/ansible/modules/extras/packaging/os/zypper_repository.py b/lib/ansible/modules/extras/packaging/os/zypper_repository.py index db553970e8..40510db9a9 100644 --- a/lib/ansible/modules/extras/packaging/os/zypper_repository.py +++ b/lib/ansible/modules/extras/packaging/os/zypper_repository.py @@ -114,22 +114,37 @@ requirements: EXAMPLES = ''' # Add NVIDIA repository for graphics drivers -- zypper_repository: name=nvidia-repo repo='ftp://download.nvidia.com/opensuse/12.2' state=present +- zypper_repository: + name: nvidia-repo + repo: 'ftp://download.nvidia.com/opensuse/12.2' + state: present # Remove NVIDIA repository -- zypper_repository: name=nvidia-repo repo='ftp://download.nvidia.com/opensuse/12.2' state=absent +- zypper_repository: + name: nvidia-repo + repo: 'ftp://download.nvidia.com/opensuse/12.2' + state: absent # Add python development repository -- zypper_repository: repo=http://download.opensuse.org/repositories/devel:/languages:/python/SLE_11_SP3/devel:languages:python.repo +- zypper_repository: + repo: 'http://download.opensuse.org/repositories/devel:/languages:/python/SLE_11_SP3/devel:languages:python.repo' # Refresh all repos -- zypper_repository: repo=* runrefresh=yes +- zypper_repository: + repo: * + runrefresh: yes # Add a repo and add it's gpg key -- zypper_repository: repo=http://download.opensuse.org/repositories/systemsmanagement/openSUSE_Leap_42.1/ auto_import_keys=yes +- zypper_repository: + repo: 'http://download.opensuse.org/repositories/systemsmanagement/openSUSE_Leap_42.1/' + auto_import_keys: yes # Force refresh of a repository -- zypper_repository: repo=http://my_internal_ci_repo/repo name=my_ci_repo state=present runrefresh=yes +- zypper_repository: + repo: 'http://my_internal_ci_repo/repo + name: my_ci_repo + state: present + runrefresh: yes ''' REPO_OPTS = ['alias', 'name', 'priority', 'enabled', 'autorefresh', 'gpgcheck']