Saravanan666/pypi-org huggingface dataset:
Package: ansible-lint-custom-strict-naming
ansible-lint-custom-strict-namingAnsible is a powerful tool for configuration management.
But it is difficult to maintain the YAML playbook quality.
Variable maintenance is one of the difficult tasks because they can be overwritten unexpectedly,
if you don't care about such likeprecedenceand position where variables are defined.This is a strict rule for variable naming, usingansible-lint.
Strict naming rule is useful to avoid name collision and to search defined position.Rulesvar_name_prefix<role_name>_role__,<task_name>_tasks__prefixVariables defined in<role_name>_role__roles/<role_name>/tasks/<role_name>_tasks__<not_roles>/**/tasks/In ansible-lint,var-naming[no-role-prefix]require to use<role_name>_as prefix. But it is not enough to avoid name collision or search defined position. So, I add_role__or_tasks__to the prefix.var__,const__var__prefixVariables dynamically defined byansible.builtin.set_factorregisterconst__prefixVariables dynamically defined byansible.builtin.set_factorregisterVariables statically defined in such like inventory's vars, group_vars, host_vars and etc.Vars intasks/<name>.ymlorroles/<name>/tasks/main.yml<name>_role__var__prefixThese variables are dynamically defined inroles/<name>/tasks/main.yml.<name>_role__const__prefixThese variables are defined inroles/<name>/vars/main.ymland shouldn't be changed dynamically.some_role__arg__prefixThese variables are defined byansible.builtin.include_role'svarskey and shouldn't be changed dynamically.some_role__argsThese variables are defined byansible.builtin.include_role'svarskey and shouldn't be changed dynamically.This is useful when you want to send vars as dict.-name:Sampleansible.builtin.include_role:name:some_rolevars:some_role__args:key1:value1key2:value2examplestasks:-name:Some taskansible.builtin.include_role:name:<role_name>vars:some_role__const__one:value1some_role__const__two:value2OthersDouble underscores?Single underscore (_) is used to separate words. Double underscores (__) are used to separate chunks for readability.examplesvar__send_message__user_idvar__send_message__contentsome_role__const__app_config__namesome_role__const__app_config__tokensome_role__const__app_config__versionDocsArticlesansible-lint のカスタムルールを利用して Ansible 内での変数命名規則を縛ってみた話
Package: ansible-lint-junit
Ansible-lint-junitTheansible-lintto JUnit converter.Installationvia pip:pipinstallansible-lint-junitUpdatingvia pip:pipinstallansible-lint-junit--upgradeUsage:You can runansible-linton your playbook(s) and redirect output to pipeansible-lintplaybook.yml-p--nocolor|ansible-lint-junit-oansible-lint.xmlYou can use a temporary file to store the output ofansible-lint.
After that runansible-lint-junitand pass generated file to itansible-lint-p--nocoloryour_fancy_playbook.yml>ansible-lint.txt
ansible-lint-junitansible-lint.txt-oansible-lint.xmlOutputIf there are any lint errors, full JUnit XML will be created.If there are no errors, empty JUnit XML will be created, this is for
i.e.BambooJUnit parser plugin compatibility.It will break build if XML is missing or incorrect, and there is really no way of generating XML with"PASSED"tests
in case of linter.LicenseThe ansible-lint-junit project is distributed under the [MIT] license.
Package: ansible-lint-to-junit-xml
Convert ansible-lint outputs to a jUnit valid xml tests result file.QuickstartInstallansible-lint-to-junit-xmlin your preferred Python envpipinstallansible-lint-to-junit-xmlRunansible-linton the desired files and pipe toansible-lint-to-junit-xmlansible-lint-q-p<fileordirectly>|ansible-lint-to-junit-xml>results/ansible-lint-results.xmlAlternatively you can runansible-lintseparately fromansible-lint-to-junit-xmland use a file to pass the outputansible-lint-q-p<fileordirectly>>ansible-lint-results.txtansible-lint-to-junit-xmlansible-lint-results.txt>results/ansible-lint-results.xmlNote:ansible-lintmust run with-pfor the output to be machine parsableFeaturesPipe output directly fromansible-lintcallOutput XML file is compliant withjenkins junit5 Schema.Built usingNekroze/cookiecutter-pypackageThis project appeared as an alternative towasilak’s ansible-lint-junit.ExampleRunningansible-linton a file results in:playbooks/test_playbook.yml:41: [E303] curl used in place of get_url or uri module
playbooks/tasks/example_task.yml:28: [E601] Don't compare to literal True/FalseRunningansible-lintand piping the output toansible-lint-to-junit-xmllooks line this:ansible-lint-q-pplaybooks/test_playbook.yml|ansible-lint-to-junit-xmlWould result in:<?xml version="1.0" ?><testsuites><testsuiteerrors="2"name="ansible-lint"tests="2"><testcasename="[E303] curl used in place of get_url or uri module"><failuremessage="playbooks/test_playbook.yml:41: [E303] curl used in place of get_url or uri module"type="ansible-lint">ansible-linterror:[E303]curlusedinplaceofget_urlorurimoduleansible-linterrordescription:[E303]curlusedinplaceofget_urlorurimodulefilename:playbooks/test_playbook.ymllinenr:41</failure></testcase><testcasename="[E601] Don't compare to literal True/False"><failuremessage="playbooks/tasks/example_task.yml:28: [E601] Don't compare to literal True/False"type="ansible-lint">ansible-linterror:[E601]Don'tcomparetoliteralTrue/Falseansible-linterrordescription:[E601]Don'tcomparetoliteralTrue/Falsefilename:playbooks/tasks/example_task.ymllinenr:28</failure></testcase></testsuite></testsuites>DocumentationThe full documentation is athttp://ansible-lint-to-junit-xml.rtfd.org.History0.1.0 (2019-07-30)First release on PyPI.
Package: ansible-mdgen
ansible-mdgenAnsible-mdgen is a package used to auto generate documentation for an ansible role.To installpip install ansible-mdgenTo runCall ansible-mdgen passing in the path to the roleansible-mdgen <path_to_role>DocumentationSeeherefor full documentation.CreditsThe idea for this project is based on (and includes some code from)ansible-autodocby Andres Bott so credit to him for his work.
Package: ansible-mkdocs
ansible-documentAutomatically document ansible roles.ConceptGenerate documentation automatically by looking up a role's content.Usage$ansible-mkdocspath/to/role#ex:$ansible-mkdocsexamples/install_gitlabname | value | location------|------|------gitlab_package_script_url | https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | vars/main.ymlgitlab_interface | {{ ansible_default_ipv4['interface'] }} | defaults/main.ymlgitlab_addr | {{ hostvars[inventory_hostname]['ansible_' + gitlab_interface]['ipv4']['address']  }} | defaults/main.ymlgitlab_install | yes | defaults/main.ymlHow does it work?Generate a list with modules and their valuesExample: copy will be used, register the mode, required, ...Lookup every directory (files, tasks, vars, ...) and fetch informationFor every directory, generate the associated templateAggregate every generated templatesAdd metadataHas testsHas moleculeMeta from meta/Output markdown
Package: ansible-modules-consul-acl
ansible-modules-consul-aclAnsible modules for theConsul ACL system:consul_acl_policyconsul_acl_tokenInstallationInstall using pip:pip install ansible-modules-consul-aclThe modules have no external dependencies except Ansible.UsageThe documentation for each module is mostly complete - useansible-docto view it.Example-name:Create ACL policyconsul_acl_policy:name:example# Rules specified as an HCL stringrules:|service "example" {policy = "write"}state:presenturl:https://localhost:8500token:a22c5e4f-0f48-4907-82db-843c6baf75be# Requires acl:writeregister:consul_acl_policy-name:Create ACL tokenconsul_acl_token:description:Example token# Policies specified as a list of PolicyLink objects: https://www.consul.io/api/acl/tokens.html#policiespolicies:-id:"{{consul_acl_policy.id}}"local:truestate:presenturl:https://localhost:8500token:a22c5e4f-0f48-4907-82db-843c6baf75be# Requires acl:writeregister:consul_acl_tokenEnvironment variablesSome of the environment variables for theConsul CLIwill be used if they are defined:CONSUL_HTTP_ADDRfor theurlparameter. Prefix withhttps://instead of settingCONSUL_HTTP_SSL=trueCONSUL_HTTP_TOKENfor thetokenparameterCONSUL_CLIENT_CERTfor theclient_certparameterCONSUL_CLIENT_KEYfor theclient_keyparameterTesting locallyTo run the functional tests, set the following environment variables
from the project root directory:exportANSIBLE_LIBRARY="$PWD/ansible/modules/consul_acl"exportANSIBLE_MODULE_UTILS="$PWD/ansible/module_utils"Then run the test playbooks in a Python environment withoutansible-modules-consul-aclinstalled.
Package: ansible-modules-dcos
Ansible modules for DC/OS.UsageCreate a user:- hosts: localhost
  tasks:
    - dcos_user:
        uid: "bobslydell"
        description: 'bobslydell'
        password: 'fooBar123ASDF'
        state: present
        dcos_credentials: "{{ dcos_facts.ansible_facts.dcos_credentials }}"Create a group:- dcos_group: gid="bobs" description='the bobs'Create a ACL:- dcos_acl:
    rid: "dcos:adminrouter:service:marathon-bobs"
    description: "Bob acl"Add user to ACL:- dcos_acl_user:
    rid: "dcos:adminrouter:service:marathon-bobs"
    uid: "bobslydell"
    permission: "read"Add group to ACL:- dcos_acl_group:
    rid: "dcos:adminrouter:service:marathon-bobs"
    gid: "bobs"
    permission: "read"Print the DC/OS token:- debug: msg="{{lookup('dcos_token')}}"Print the DC/OS token header:- debug: msg="{{lookup('dcos_token_header')}}"Get marathon leader:- dcos_marathon_leader:
  register: marathonLicenseMIT
Package: ansible-modules-morpheus
Ansible Modules MorpheusInstall this module:viapippipinstallansible-modules-morpheusviaansible-galaxyansible-galaxyinstall'git+https://github.com/gomorpheus/ansible-modules-morpheus.git'Environment VariablesIf you choose to use env vars the following variables can be exported to the environment you are controlling with ansible in order to authenticate to your Morpheus Appliance:MORPH_ADDR : url for Morpheus ApplianceMORPH_AUTHTYPE: authorization type for Morpheus (token or userpass)MORPH_USER: Morpheus appliance username for userpass authtypeMORPH_PASSWORD: Morpheus appliance user password for userpass authtypeMORPH_TOKEN: Morpheus api token for token authtypeMORPH_SSL_VERIFY: Boolean for verifying sslAddition variables for specific modules:MORPH_SECRET: Morpheus secret key for Cypher value reads in morph_cypher moduleArgumentsAlternatively you can pass arguments to the module by using discrete variables in your task module.  Args that are supported are:baseurl: url for Morpheus Applianceauthtype: authorization type for Morpheus (token or userpass)api_token: Morpheus api token for token authtypeusername: Morpheus appliance username for userpass authtypepassword: Morpheus appliance user password for userpass authtypessl_verify: Boolean for verifying SSLFor specific modulessecret_key: Morpheus secret key for Cypher value reads in morph_cypher moduleModule Examplesmorph_cypher-hosts:footasks:-name:gettokenmorph_cypher:baseurl:"https://sandbox.morpheusdata.com"secret_key:"password/spark"authtype:tokenssl_verify:Falseregister:results-debug:var=results.secretor explicitly passing the api_token as a var:-hosts:footasks:-name:gettokenmorph_cypher:baseurl:"https://sandbox.morpheusdata.com"secret_key:"secret/nooneknows"authtype:tokenapi_token:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"register:resultsLookup Plugin Examplesmorph_cypher-debug:msg:"{{ lookup('morph_cypher', 'baseurl=https://sandbox.morpheusdata.com authtype=token api_token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx secret_key=password/spark')}}"-debug:msg:"{{ lookup('morph_cypher', 'baseurl=https://sandbox.morpheusdata.com authtype=userpass username=slim_shady password=password secret_key=secret/hello') }}"-debug:msg:"{{ lookup('morph_cypher', 'baseurl=https://sandbox.morpheusdata.com authtype=token api_token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ssl_verify=False secret_key=key/256/myKey') }}"LicenseMIT
Package: ansible-modules-pm2
ansible-modules-pm2Ansible Module to Manage Processes viaPM2Manage the state of processes via pm2 process managerStart/Stop/Restart/Reload/Delete applicationsTested on:Host Python: 3.8Target host Python: 2.7, 3.5, 3.6, 3.7, 3.8Ansible: 2.8.10, 2.9.6 (Should work with older versions)InstallationInstall via pip:pipinstallansible-modules-pm2PM2 package have to be installed to target hosts.
For example, add following to your playbook to install pm2 globally:-npm:name:pm2global:yesUsageBasic usage is similar toserviceorsupervisorctlmodule:
specify the name and its state. To start an app, give eitherscriptorconfig.Examples----name:Start myapp with process config file, if not runningpm2:name:myappconfig:/path/to/myapp/myapp.jsonstate:started-name:Start myapp.js, if not runningpm2:name:myappscript:/path/to/myapp/myapp.jsstate:started-name:Stop process named myapp, if runningpm2:name:myappstate:stopped-name:Restart myapp, in all casespm2:name:myappstate:restarted-name:Reload myapp, in all casespm2:name:myappstate:reloaded-name:Delete myapp, if existspm2:name:myappstate:absent-name:Specify pm2 executable pathpm2:name:myappstate:startedconfig:/path/to/myapp/myapp.jsonexecutable:/path/to/myapp/node_modules/.bin/pm2-name:Also specify working directory where running pm2 commandpm2:name:myappstate:startedconfig:/path/to/myapp/myapp.jsonexecutable:/path/to/myapp/node_modules/.bin/pm2chdir:/path/to/working/directoryArgumentsParametersChoicesCommentsname (required)Name of the application.Required for all cases to check current status of appstatestarted(default)stoppedrestartedreloadedabsentdeletedstarted/stopped/absent/deletedare idempotent actions that will not run commands unless necessary.restartedwill always restart the process.reloadedwill always reload.Note thatrestartedwill fail when the process does not exist (action does not start it automatically).configProcess configuration file, in JSON or YAML format.Eitherconfigorscriptis required whenstate=started.scriptExecutalbe file to start.Eitherconfigorscriptis required whenstate=started.executablePath to pm2 executable.chdirChange into this directory before running pm2 start command.Whenstate=startedand this option is omitted, use the directory whereconfigorscriptexists.LicenseThis software is licensed under GPLv3. SeeLICENSEfor details.
Package: ansible-netbox-inventory
ToCIntroCompatibilityGroupingHosts variablesOptionsUsageIntroThis is a Netbox dynamic inventory script for Ansible.Netboxis an IP address
management (IPAM) and data center infrastructure management (DCIM) tool.
It’s nice, modern, and has good APIs … so it’s a pretty nice option to
serve as a “Source of Truth”.You can group servers as you want and based on what you have in Netbox,
you can select fields as groups or as vars for hosts. And you can use
default fields or custom fields.CompatibilityThe script tested withnetbox = v1.6andnetbox = v2.0.4,
but most probably it will work with all netbox v1.0 and above.GroupingServers could be grouped by any section in Netbox.
e.g. you can group hosts by “site, “rack”, “role”, “platform”,
or any other section in Netbox.Please remember: For grouping, API names should be used not UI names.So if you have a “site” called “US-East”, in Ansible you will get a
hosts group is called “US-East” has all hosts in that site.If that section is adefaultsection you need to put it undergroup_by.defaultif it’s a custom section (custom fields), then
put it undergroup_by.custom.Here is an example how servers will be grouped based on theirplatform.group_by:
   default:
       - platformSo if you have “Ubuntu” and “CentOS” as platforms in Netbox,
you will have 2 groups of servers that using that systems.Hosts variablesNetbox sections could be used as variables for hosts! e.g. you could use
the IP of the host in Netbox asansible_ssh_host, or use a custom
field as well.There are 3 sections here, first type isIP, second one isGeneral, and finallyCustom.Variables are defined asKey: Value. The key is what will be in
Ansible and value comes from Netbox.hosts_vars:
    ip:
        ansible_ssh_host: primary_ipHereprimary_ipwill be used as value foransible_ssh_host.Options$ netbox.py -h
usage: netbox.py [-h] [-c CONFIG_FILE] [--list] [--host HOST]

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        Path for script's configuration. Also
                        "NETBOX_CONFIG_FILE" could be used as env var to set
                        conf file path. (default: netbox.yml)

  --list                Print all hosts with vars as Ansible dynamic inventory
                        syntax. (default: False)
  --host HOST           Print specific host vars as Ansible dynamic inventory
                        syntax. (default: None)You can also set config file path through environment variableNETBOX_CONFIG_FILE.Usage$ ansible all -i netbox.py -m ping
Package: ansible-nwd
Ansible Never Write the DocIntroductionAnsible Never Write the Docprovides you an automatic way to create Ansible roles documentation.It parses all Ansible roles folders and gathers information to write them into aReadme.mdfor you.Ansible-nwdis also compatible withmolecule, it will parse your different scenarios and write them into your documentation file.ResourcesDocumentation :https://docs.ansible-nwd.comPip download :https://pypi.org/project/ansible-nwd/Docker image :https://hub.docker.com/repository/docker/laurentvasseur/ansible-nwdExampleIn this repo, you can find an example of Ansible role and allAnsible-nwdpattern available at the following path :examples/python3
Package: ansible-output-parser
The Ansible Parser is intended to parse the output that Ansible returns.InstallationSimply install using:pipinstallansible-output-parserUsagefromansible_parser.playimportPlayplay=""# populate with play outputansible=Play(play_output=play)failures=ansible.failures()Alternatively the following can be executed to read from a log file:fromansible_parser.logsimportLogslog_file=""# path to log filelog_plays=Logs(log_file=log_file)Reading from a log file will result in multiple plays as it may process plays with the same
name.
Package: ansible-parallel
ansible-parallelTL;DR:pipinstallansible-parallel
ansible-parallel*.ymlExecutes multiple ansible playbooks in parallel.For my usage, running sequentially (using asite.ymlcontaining
multipleimport_playbook) takes 30mn, running in parallel takes
10mn.Usageansible-parallelruns likeansible-playbookbut accepts multiple
playbooks. All remaining options are passed toansible-playbookso
feel free to runansible-parallel --check *.ymlfor example.ExampleIt's easy to start:$ansible-parallel*.ymlWhen it runs, it display a live update of what's going on, one line per playbook:web.yml:     TASK [common : Configure Debian repositories] *****************************
gitlab.yml:  TASK [common : Configure IP failover] *************************************
staging.yml: TASK [common : Configure Debian repositories] *****************************
dev.yml:     Done.And when it's done, it prints a full report like:# Playbook playbook-webs.yml, ran in 123s

web1.meltygroup.com         : ok=51   changed=0    unreachable=0    failed=0    skipped=12   rescued=0    ignored=0
web2.meltygroup.com         : ok=51   changed=0    unreachable=0    failed=0    skipped=12   rescued=0    ignored=0
web3.meltygroup.com         : ok=51   changed=0    unreachable=0    failed=0    skipped=12   rescued=0    ignored=0


# Playbook playbook-staging.yml, ran in 138s

staging1.meltygroup.com         : ok=64   changed=6    unreachable=0    failed=0    skipped=18   rescued=0    ignored=0


# Playbook playbook-gitlab.yml, ran in 179s

gitlab-runner1.meltygroup.com         : ok=47   changed=0    unreachable=0    failed=0    skipped=13   rescued=0    ignored=0
gitlab-runner2.meltygroup.com         : ok=47   changed=0    unreachable=0    failed=0    skipped=13   rescued=0    ignored=0
gitlab-runner3.meltygroup.com         : ok=47   changed=0    unreachable=0    failed=0    skipped=13   rescued=0    ignored=0
gitlab.meltygroup.com                 : ok=51   changed=0    unreachable=0    failed=0    skipped=12   rescued=0    ignored=0


# Playbook playbook-devs.yml, ran in 213s

dev1.meltygroup.com             : ok=121  changed=0    unreachable=0    failed=0    skipped=22   rescued=0    ignored=0
dev2.meltygroup.com             : ok=121  changed=0    unreachable=0    failed=0    skipped=22   rescued=0    ignored=0Known alternativesansible-pullansible-parallel is only good if you want to keep the push behavior of
Ansible, but if you're here you may have a lot of playbooks, and
switching toansible-pullwith a proper reporting system likeARAxargsA quick and dirty way of doing it in 3 lines of bash:ls -1 *.yml | xargs -n1 -P16 sh -c 'ansible-playbook "$$0" > "$$0.log"' ||:
grep -B1 "^\(changed\|fatal\|failed\):" *.log
echo *.yml.log | xargs -n1 sed -n -e '/^PLAY RECAP/,$$p'
Package: ansible-playbook-debugger
ansible-playbook-debugger is the tool to debug a playbook. This debugger is
invoked when the task in the playbook fails, and enables you to check actually
used module’s args, variables, facts, and so on. Also, you can fix module’s args
in the debugger, and re-run the failed task (and if it is successful, the
remaining part of the playbook runs).Seehttps://github.com/ks888/ansible-playbook-debuggerfor more details.
Package: ansible-playbook-runner
ansible-playbook-runneransible-playbook-runner is a simple wrapper for ansibleInstallationUse the package managerpipto install ansible-playbook-runner.pipinstallfoobarUsagefromansible_playbook_runnerimportRunnerRunner(['inventory_path'],'playbook_path').run()ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.
Package: ansible-please
ansible_pleaseHelper package to make running Ansible a bit smootherRun Ansible tasks and playbooks from python with ease!InstallationTo install python package from pypi:python -m pip install ansible-pleaseFrom source:python setup.py installTo install ansible plugins, likedocker_containeransible-galaxy collection install community.dockerOverviewMain Components:Inventory- Handles ansible inventory creation from input:Basic input:hosts:
    master_host:
      - 'localhost'
host_info:
  '127.0.0.1':
    'python_path': /usr/bin/python3AnsibleTask- Handles individual ansible task creationDocker Task creationfrom ansible_please.task_templates.docker_container import DockerContainer

docker_container_task = DockerContainer(
  task_description="start-test-redis",
  name="test-redis",
  image="redis:latest",
)converts to yaml:- name: '[up] start-test-redis'
  docker_container:
    name: test-redis
    image: redis:latest
    user: nobody
    keep_volumes: false
    detach: true
    tty: false
    interactive: false
    network_mode: host
    container_default_behavior: compatibility
  tags:
  - upupto start the container,downto tear it downPlaybook- Handles playbook creationfrom ansible_please.playbook import Playbook
p = Playbook(name="Set up master_host",
           hosts="master_host",
           tasks=[docker_container_task.up(), docker_container_task.down()])converts to yaml:- name: Set up master_host
  hosts: master_host
  gather_facts: true
  tasks:
  - name: '[up] start-test-redis'
    docker_container:
      name: test-redis
      image: redis:latest
      user: nobody
      keep_volumes: false
      detach: true
      tty: false
      interactive: false
      network_mode: host
      container_default_behavior: compatibility
    tags:
    - up
  - name: '[down] start-test-redis'
    docker_container:
      name: test-redis
      state: absent
      user: nobody
      keep_volumes: false
      detach: true
      tty: false
      interactive: false
      network_mode: host
      container_default_behavior: compatibility
    tags:
    - downAnsibleRunner- main handler for running playbooksr = AnsibleRunner(playbook=p, input_path="test_input.yml") # or pass in Inventory class
r.up()See full examplesFree software: MIT licenseDocumentation:https://ansible-please.readthedocs.io.CreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2020-12-22)First release on PyPI.