Giter Club home page Giter Club logo

ansible-lastpass-inventory's Introduction

Dynamic LastPass Ansible Inventory

Requires a LastPass account and the lpass client.

The lastpass_inventory.py script uses the lastpass_inventory.yml configuration file to fetch the named servers from the current logged in LastPass account using lpass, and then generate an Ansible inventory.

Examples and Usage

The lastpass_inventory.yml configuration file names and fetches the hosts using name: identifier, where the name variable is what the host will be named in the inventory and the identifier is used to identify the host in LastPass.

Both the name and the ID number from e.g. lpass ls can be used as an identifier for a host.

If the ID is omitted, the name will be used as the identifier.

Note that the script will fail if the name or ID is incorrect or missing.

The LastPass user and password fields will be used to populate ansible_user, ansible_password and ansible_become_password. The ansible_host address is the extracted netloc from the LastPass url field using urllib.parse.urlparse.

Example lpass ls output:

servers
    ansible-managed
        test-server-01 [id: 3024014487647346952]
        test-server-02 [id: 7815456364361241116]

Configuration file based on the above output:

---
lastpass_hosts:
  test-server-01:
  test-server-02: test-server-02
  webserver: test-server-01
  database: "7815456364361241116"
...

Running ansible-inventory -i lastpass_inventory.py --list --yaml will then generate the following inventory:

all:
  children:
    lastpass_hosts:
      hosts:
        database:
          ansible_become_password: SuperSecretLastPass
          ansible_host: 10.0.1.2
          ansible_password: SuperSecretLastPass
          ansible_user: ansibleuser
        test-server-01:
          ansible_host: 10.0.1.1
          ansible_user: ansibleuser
        test-server-02:
          ansible_become_password: SuperSecretLastPass
          ansible_host: 10.0.1.2
          ansible_password: SuperSecretLastPass
          ansible_user: ansibleuser
        webserver:
          ansible_host: 10.0.1.1
          ansible_user: ansibleuser
    ungrouped: {}

ansible-lastpass-inventory's People

Contributors

konstruktoid avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-lastpass-inventory's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/issues.yml
  • pozil/auto-assign-issue v2.0.0@c5bca5027e680b9e8411b826d16947afd8c76b32
.github/workflows/linting.yml
.github/workflows/scorecards.yml
  • actions/checkout v4.1.6@a5ac7e51b41094c92402da3b24376905380afc29
  • ossf/scorecard-action v2.3.3@dc50aa9510b46c811795eb24b2f1ba02a914e534
  • actions/upload-artifact v4.3.3@65462800fd760344b1a7b4382951275a0abb4808
  • github/codeql-action v3.25.5@b7cec7526559c32f1616476ff32d17ba4c59b2d6
pip_requirements
requirements-dev.txt
requirements.txt

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.