# -*- coding: utf-8 -*-
from setuptools import setup

package_dir = \
{'': 'src'}

packages = \
['agileupstate']

package_data = \
{'': ['*']}

install_requires = \
['PyYAML>=5.4.1,<6.0.0',
 'click>=8.1,<9.0',
 'hvac>=1.0.2,<2.0.0',
 'prettytable>=3.3.0,<4.0.0',
 'pywinrm>=0.4.3,<0.5.0']

entry_points = \
{'console_scripts': ['agileupstate = agileupstate.cli:cli']}

setup_kwargs = {
    'name': 'agileupstate',
    'version': '0.0.43',
    'description': 'State mangement tool for Future Agile CICD',
    'long_description': '# AgileUp State\n\nPython 3.8+ project to manage AgileUP pipeline states with the following features:\n\n* Linux and Windows compatible project.\n* Defines state model.\n* Saves and fetches states from vault.\n* Exports private key for Linux SSH connections.\n* Exports client PKI data for Windows WinRM connections.\n* Creates cloud init zip file for mTLS connection data to Windows WinRM hosts.\n* Exports ansible inventories for both Linux(SSH) and Windows(WinRM) connections.\n* Provides simple connectivity tests.\n\n## Prerequisites\n\nThis project uses poetry is a tool for dependency management and packaging in Python. It allows you to declare the \nlibraries your project depends on, it will manage (install/update) them for you. \n\nUse the installer rather than pip [installing-with-the-official-installer](https://python-poetry.org/docs/master/#installing-with-the-official-installer).\n\n```sh\npoetry self add poetry-bumpversion\n```\n\n```sh\npoetry -V\nPoetry (version 1.2.0)\n```\n\n### Windows Path\n\nInstall poetry from powershell in admin mode.\n\n```shell\n(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -\n```\n\nThe path will be `C:\\Users\\<YOURUSER>\\AppData\\Roaming\\Python\\Scripts\\poetry.exe` which you will need to add to your system path.\n\n### Windows GitBash\n\nWhen using gitbash you can setup an alias for the poetry command:\n\n```shell\nalias poetry="\\"C:\\Users\\<YOURUSER>\\AppData\\Roaming\\Python\\Scripts\\poetry.exe\\""\n```\n\n## Getting Started\n\n```sh\npoetry update\n```\n\n```sh\npoetry install\n```\n\n## Development\n\nThis project uses the [hvac](https://github.com/hvac/hvac) python module and to develop locally you can run vault\nas a docker service as detailed here [local docker vault](https://hub.docker.com/_/vault). For local development vault \nsetup follow the [VAULT](VAULT.md) guide for information.\n\nCheck your connection with the following command, note in development mode vault should not be sealed.\n\n```shell\nexport VAULT_ADDR=\'http://localhost:8200\'\nexport VAULT_TOKEN=\'8d02106e-b1cd-4fa5-911b-5b4e669ad07a\'\n\npoetry run agileupstate check\n```\n\n## Required Environment State Variables\n\n| Variable         | Description                                                     |\n|------------------|-----------------------------------------------------------------|\n| SIAB_ID          | Unique environment ID.                                          |\n| SIAB_CLOUD       | Cloud vendor API mnemonic.                                      |\n| SIAB_LOCATION1   | Cloud vendor defined cloud location, uksouth, etc.              |\n| SIAB_LOCATION2   | Cloud vendor defined cloud location, UK South, etc.             |\n| SIAB_CONTEXT     | Environment context, e.g. dev. test, prod.                      |\n| SIAB_VALUES_PATH | Vault path to common environment values to be exported.         |\n| SIAB_DOMAIN      | Optional public domain that overrides cloud provided DNS names. |\n\n`SIAB_LOCATION`: Azure has a different location string between "accounts" and "resources" and only `uksouth` is useful\nto the automation, but we must also provide `UK South` for resource groups.\n\n`SIAB_VALUES_PATH`: Rather than load variables into the delivery platform environment, there can be many, a better option\nis to define a YML file that contains all the required common variables for a specific environment and have the user upload\nthat to vault. This application can then download the YML data file and convert it into an exports file that can be sourced \nby the pipelines. These environment values that are exported can then be used by this project and other utilities such as\nterraform, ansible and powershell.\n\n`SIAB_DOMAIN`: Cloud DNS services might in some cases provide a DNS domain that is not the same as the public internet\ndomain required by the project, for example server1.uksouth.cloudapp.azure.com might optionally be server1.meltingturret.io.\n\n`username/password`: These values are common across the environment, for example Ubuntu Azure images use a `username=azureuser`,\nand so it simplifies configuration if the same credentials are used for Linux and Windows environments running in Azure for \nadministration access, client administration access as well as PFX certificate files used on Windows for WinRM certificate \nauthentication. For AWS `ubuntu` is the username for Ubuntu images the same approach can be taken there.\n\n**Required environment inputs:**\n\n> These values should be setup in your CD platforms environment variables.\n\n```shell\nexport SIAB_ID=001\nexport SIAB_CLOUD=arm\nexport SIAB_LOCATION1=uksouth\nexport SIAB_LOCATION2="UK South"\nexport SIAB_CONTEXT=dev\nexport SIAB_VALUES_PATH=siab-state/001-arm-uksouth-dev/siab-values/siab-values.yml\n```\n\n**Required values inputs (stored in vault path `SIAB_VALUES_PATH`):**\n\n```yaml\nconnection:\n  url: https://server1.meltingturret.io:5986\n  username: azureuser\n  password: mypassword\n  ca_trust_path: siab-client/chain.meltingturret.io.pem\n  cert_pem: siab-client/azureuser@meltingturret.io.pem\n  cert_key_pem: siab-client/azureuser@meltingturret.io.key\ncloud:\n  group_owner: Paul Gilligan\n  group_department: DevOps\n  group_location: UK South\n```\n\n## Required Supporting Data\n\nSome data is generated only once and thus can be uploaded to vault manually. \n\n**Uploading values file:**\n\n```shell\nbase64 ./siab-values.yml | vault kv put secret/siab-state/001-arm-uksouth-dev/siab-values/siab-values.yml file=-\n```\n\n**Uploading pfx files:**\n\n```shell\nbase64 ./server1.meltingturret.io.pfx | vault kv put secret/siab-pfx/server1.meltingturret.io.pfx file=-\nbase64 ./azureuser@meltingturret.io.pfx | vault kv put secret/siab-pfx/azureuser@meltingturret.io.pfx file=-\n```\n\n**Uploading pki files:**\n\n```shell\nbase64 ./chain.meltingturret.io.pem | vault kv put secret/siab-client/chain.meltingturret.io.pem file=-\nbase64 ./azureuser@meltingturret.io.key | vault kv put secret/siab-client/azureuser@meltingturret.io.key file=-\nbase64 ./azureuser@meltingturret.io.pem | vault kv put secret/siab-client/azureuser@meltingturret.io.pem file=-\n```\n\n## Provision Use Case\n\nExample steps required for the Windows terraform provision use case shown below. \n\n```shell\nagileupstate cloud-init --server-path=siab-pfx/ags-w-arm1.meltingturret.io.pfx --client-path=siab-pfx/devops@meltingturret.io.pfx\nagileupstate create\nsource ./siab-state-export.sh                                                \nterraform init\nterraform apply -auto-approve\nagileupstate save\n```\n\nExample steps required for the Linux terraform provision use case shown below. \n\n```shell\nagileupstate create\nsource ./siab-state-export.sh                                                \nterraform init\nterraform apply -auto-approve\nagileupstate save\n```\n\n## Destroy Use Case\n\nExample steps required for recovering system state use case shown below which might be for example to destroy an environment. \n\n```shell\nagileupstate load\nsource ./siab-state-export.sh                                                \nterraform init\nterraform destroy -auto-approve\n```\n\n## Ansible Use Case\n\nExample steps required for the Windows ansible use case shown below. \n\n```shell\nagileupstate load\nsource ./siab-state-export.sh                                                  \nagileupstate inventory-windows --ca-trust-path=siab-client/chain.meltingturret.io.pem --cert-pem=siab-client/azureuser@meltingturret.io.pem --cert-key-pem=siab-client/devops@meltingturret.io.key\nansible-inventory -i inventory.ini --list\nansible -i inventory.ini "${TF_VAR_siab_name_underscore}" -m win_ping\n```\n\nExample steps required for the Linux ansible use case shown below. \n\n```shell\nagileupstate load\nsource ./siab-state-names.sh                        \nagileupstate inventory-linux\nansible-inventory -i inventory.ini --list\nANSIBLE_HOST_KEY_CHECKING=True ansible -i inventory.ini --user "${TF_VAR_admin_username}" "${TF_VAR_siab_name_underscore}" -m ping\n```\n\n## Exports Use Case\n\nThe `yml` file from `SIAB_VALUES_PATH` is exported to the file `siab-state-export.sh` with the contents as shown in the \nexample below which can then be used by downstream utilities. \n\n```shell\nexport SIAB_URL=https://server1.meltingturret.io:5986\nexport SIAB_USERNAME=azureuser\nexport SIAB_PASSWORD=mypassword\nexport SIAB_CA_TRUST_PATH=siab-client/chain.meltingturret.io.pem\nexport SIAB_CERT_PEM=siab-client/azureuser@meltingturret.io.pem\nexport SIAB_CERT_KEY_PEM=siab-client/azureuser@meltingturret.io.key\nexport TF_VAR_group_owner=Paul Gilligan\nexport TF_VAR_group_department=DevOps\nexport TF_VAR_group_location=UK South\nexport TF_VAR_admin_username=azureuser\nexport TF_VAR_admin_password=mypassword\nexport TF_VAR_siab_name=001-arm-uksouth-dev\nexport TF_VAR_siab_name_underscore=001_arm_uksouth_dev\n```\n\n```shell\nsource ./siab-state-export.sh\n```\n\n## Cloud Init Data Use Case\n\nExample cloud init command that generates the zip file that is loaded onto Windows machines for WimRM certificate authentication. \n\n```shell\npoetry run agileupstate cloud-init --server-path=siab-pfx/ags-w-arm1.meltingturret.io.pfx --client-path=siab-pfx/azureuser@meltingturret.io.pfx\n```\n\n## Ansible Windows Inventory Use Case\n\n`inventory.ini` is generated with the target(s) and configuration information for a successful SSH connection from Ansible. \n\n**When `export SIAB_DOMAIN=meltingturret.io`:**\n\n```ini\n[001_arm_uksouth_dev]\nags-w-arm1.meltingturret.io\n[001_arm_uksouth_dev:vars]\nansible_user=azureuser\nansible_password=heTgDg!J4buAv5kc\nansible_connection=winrm\nansible_port=5986\nansible_winrm_ca_trust_path=chain.meltingturret.io.pem\nansible_winrm_cert_pem=azureuser@meltingturret.io.pem\nansible_winrm_cert_key_pem=azureuser@meltingturret.io.key\nansible_winrm_transport=certificate\n```\n\n## Ansible Linux Inventory Use Case\n\n`inventory.ini` is generated with the target(s) and configuration information for a successful SSH connection from Ansible. \n\n**When `export SIAB_DOMAIN=meltingturret.io`:**\n\n```ini\n[001_arm_uksouth_dev]\nags-w-arm1.meltingturret.io ansible_ssh_private_key_file=vm-rsa-private-key.pem\n```\n\n## Run\n```sh\npoetry run agileupstate\n```\n\n## Lint\n```sh\npoetry run flake8\n```\n\n## Test\n```sh\npoetry run pytest\n```\n\n## Publish\n\n* By default we are using [PYPI packages](https://packaging.python.org/en/latest/tutorials/installing-packages/). \n* Create yourself an access token for PYPI and then follow the instructions.\n\n```sh\nexport PYPI_USERNAME=__token__ \nexport PYPI_PASSWORD=<Your API Token>\npoetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD\n```\n\n## Versioning\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Agile-Solutions-GB-Ltd/agileup/tags). \n\n## Releasing\n\nWe are using [poetry-bumpversion](https://github.com/monim67/poetry-bumpversion) to manage release versions.\n\n```sh\npoetry version patch\n```\n\n## Dependency\n\nOnce the release has been created it is now available for you to use in other python projects via:\n\n```sh\npip install agileupstate\n```\n\nAnd also for poetry projects via:\n\n```sh\npoetry add agileupstate\n```\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## License\n\nThis project is licensed under the Apache License, Version 2.0 - see the [LICENSE](LICENSE) file for details\n\n\n\n',
    'author': 'agileturret',
    'author_email': 'Paul.Gilligan@agilesolutions.co.uk',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://github.com/Agile-Solutions-GB-Ltd/agileupstate',
    'package_dir': package_dir,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
