{"id":14984573,"url":"https://github.com/lj020326/ansible-datacenter","last_synced_at":"2025-10-23T22:31:36.140Z","repository":{"id":37050820,"uuid":"331429538","full_name":"lj020326/ansible-datacenter","owner":"lj020326","description":"ansible roles and site.yml tags to setup/configure datacenter","archived":false,"fork":false,"pushed_at":"2024-12-08T14:34:15.000Z","size":161008,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-30T21:34:43.249Z","etag":null,"topics":["ansible","ansible-datacenter","ansible-docker","ansible-linux","ansible-molecule","ansible-roles","ansible-windows","docker-compose","docker-jenkins","docker-stack","jenkins","jenkins-config-as-code"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lj020326.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-20T20:54:16.000Z","updated_at":"2024-12-08T14:34:19.000Z","dependencies_parsed_at":"2024-11-08T15:37:44.701Z","dependency_job_id":null,"html_url":"https://github.com/lj020326/ansible-datacenter","commit_stats":{"total_commits":818,"total_committers":4,"mean_commits":204.5,"dds":0.0819070904645477,"last_synced_commit":"335b96e07cf8ba47075cd282fcf289bba1017423"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lj020326%2Fansible-datacenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lj020326%2Fansible-datacenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lj020326%2Fansible-datacenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lj020326%2Fansible-datacenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lj020326","download_url":"https://codeload.github.com/lj020326/ansible-datacenter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237890777,"owners_count":19382562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-datacenter","ansible-docker","ansible-linux","ansible-molecule","ansible-roles","ansible-windows","docker-compose","docker-jenkins","docker-stack","jenkins","jenkins-config-as-code"],"created_at":"2024-09-24T14:09:17.257Z","updated_at":"2025-10-23T22:31:26.120Z","avatar_url":"https://github.com/lj020326.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# ansible-datacenter\n\n[![Ansible-Lint](https://github.com/lj020326/ansible-datacenter/actions/workflows/ansible-lint.yml/badge.svg)](https://github.com/lj020326/ansible-datacenter/actions/workflows/ansible-lint.yml)\n[![Inclusivity-Lint](https://github.com/lj020326/ansible-datacenter/actions/workflows/inclusivity-lint.yml/badge.svg)](https://github.com/lj020326/ansible-datacenter/actions/workflows/inclusivity-lint.yml)\n[![YAML-Lint](https://github.com/lj020326/ansible-datacenter/actions/workflows/yaml-lint.yml/badge.svg)](https://github.com/lj020326/ansible-datacenter/actions/workflows/yaml-lint.yml)\n[![Molecule Tests](https://github.com/lj020326/ansible-datacenter/actions/workflows/molecule.yml/badge.svg)](https://github.com/lj020326/ansible-datacenter/actions/workflows/molecule.yml)\n[![License](https://img.shields.io/badge/license-GPLv3-brightgreen.svg?style=flat)](LICENSE)\n\n## Build Status\n\nThis is an ansible playbook that will configure your datacenter based on multi-OS-platform roles on Ubuntu/Centos/Debian linux and windows servers.\n\nThe [bootstrap_vm_template.yml](./bootstrap_vm_template.yml) playbook is used by [vm-templates repo](https://github.com/lj020326/vm-templates) to build VMware Ubuntu, Debian, and Centos templates. \n\nThe 'ansible' and 'vm template build' pipelines are both automated using the [pipeline-automation-lib](https://github.com/lj020326/pipeline-automation-lib/) jenkins library.\n\n## Linux OS Platform Molecule Tests\n\nTesting of the linux OS bootstrap playbooks is performed by molecule with platforms defined in ['molecule.yml'](molecule/default/molecule.yml) and the ['converge.yml'](molecule/default/converge.yml).  Molecule scenarios have been set up to include the overall platform provisioning/orchestration role converge playbook for [bootstrap_linux](./molecule/bootstrap_linux/converge.yml) as well as multiple key roles invoked within the `bootstrap_linux` orchestration role to allow/enable isolated/granular testing when and as needed.\n\nFurther details on running molecule tests from this repo can be found in the 'Run molecule tests' section of the [molecule/README.md](tests/README.md).\n\nThe molecule test pipeline is set up in the github actions [ci.yml](.github/workflows/ci.yml) and the molecule converge test results for each platform can be viewed on [github actions results page](https://github.com/lj020326/ansible-datacenter/actions).\n\nThe systemd-python enabled docker images used by the molecule tests can be found on [dockerhub](https://hub.docker.com/repositories/lj020326?search=systemd).  The corresponding dockerfile image definitions for the systemd-python enabled docker platform containers used in the molecule tests can be found [here](https://github.com/lj020326/systemd-python-dockerfiles).  \n\n## Ansible Developer Environment\n\nA companion [ansible-developer repository here](https://github.com/lj020326/ansible-developer) can be used to bootstrap/set-up an ansible development environment.\n\nThe installer shell script from this repo will:\n1) create the local developer repo directory under $HOME/repos/ansible\n2) clone the repo into the developer's local repo directory at $HOME/repos/ansible/ansible-developer\n3) setup/synchronize the developer's bash environment with source bash files located in `files/scripts/bashenv`\n4) source the bash env\n\nFor install from public github: \n\n```shell\n$ INSTALL_REMOTE_SCRIPT=\"https://raw.githubusercontent.com/lj020326/ansible-developer/main/install.sh\" \u0026\u0026 bash -c \"$(curl -fsSL ${INSTALL_REMOTE_SCRIPT})\"\n```\n\nThe environment setup from the aforementioned repo is utilized to prepare the developer environment to:\n1) run playbooks\n2) run molecule testing \n\n## Summary\n\n- Collection of Ansible roles, playbooks, plugins, and modules\n- OS image build systems (packer, vsphere)\n- Runtime environment software installs\n- Runtime environment application deployments\n- Runtime machine instance maintenance\n\n### Example ansible image build workflow\n\n\u003e Workflow for ansible provisioning integration with image build systems\n\n```mermaid\ngraph TD;\n    A[Packer Build Spec] --\u003e B{Virtual Machine}\n    B --\u003e|yes| C[\"Install OS (Centos/Ubuntu/Debian)\"]\n    B --\u003e|no| D[Container Build]\n    C --\u003e E[Post OS Install - VM Base VM Template Image]\n    D --\u003e F[Post OS Install - OS Base Container Image]\n    E --\u003e G[\"Ansible Provision Role + Harden Security Profile (VM/Cloud/Container)\"]\n    F --\u003e G[\"Ansible Provision Role + Harden Security Profile (VM/Cloud/Container)\"]\n    G --\u003e H[\"Ansible Post OS Install - Software Install\"]\n    H --\u003e I[Ansible Application Deploy]\n    I --\u003e J[Ansible Maintenance]\n\n```\n\n\n## Prerequisites\n\n1.  Clone this Ansible deployment playbook\n```\ngit clone https://github.com/lj020326/ansible-datacenter.git\n```\n\n2. Setup galaxy collections/roles to be used: *This is internally performed by script if using to run on remote ansible/control node\n\n```\n## install collections\nansible-galaxy collection install -r ./collections/requirements.yml\n\n## install roles\nansible-galaxy install -r ./roles/requirements.yml\n```\n\n3. Add host info to hosts.yml inventory and ping the nodes\n\n```shell\nansible -i inventory/hosts.yml all -m ping -b -vvvv\n```\n\n4. Create the vault file used to protect important data in source control.\n    For more information go [here](http://docs.ansible.com/playbooks_vault.html).\n    Also, [see here for an example of the vault file used for this project](vars/README.md) \n\n    The vault file used has to have the name vars/vault.yml. \n    ```shell\n    # create private file\n    ansible-vault create vars/vault.yml\n    ```\n\n    Running the command above will ask you for a password to encrypt with, and open an editor. In that file set the variables highlighted in the vault.yml.example file.\n\n\n## Jenkins Ansible Jobs\n\n### Ansible role to setup docker jenkins control node\n\nAn ansible role is used to setup all docker stack instances.\n\nThe `bootstrap_docker_stack` ansible role used to stand up the docker stack [can be found here](https://github.com/lj020326/ansible-datacenter/tree/main/roles/bootstrap_docker_stack).\n\nThe [`bootstrap_docker_stack` ansible role](https://github.com/lj020326/ansible-datacenter/tree/main/roles/bootstrap_docker_stack) contains the [__jenkins config-as-code (jcac) yaml definition__](https://github.com/lj020326/ansible-datacenter/blob/main/roles/bootstrap_docker_stack/templates/jenkins_jcac/jenkins_casc.yml.j2) in template form used to setup the jenkins jcac instance.\n\n[The jcac definition can be found here](https://github.com/lj020326/ansible-datacenter/blob/main/roles/bootstrap_docker_stack/templates/jenkins_jcac/jenkins_casc.yml.j2).  \n\n\n### Setup pipeline automation library used by all jenkins jobs\n\nThe pipeline automation library used can be found [here](https://github.com/lj020326/pipeline-automation-lib).\n[The pipeline automation library](https://github.com/lj020326/pipeline-automation-lib) defines the shared jenkins templates that are used throughout all of the jenkins ansible pipelines.  \n\nConfigure the library in jenkins as seen below.\n![Jenkins - Configure shared Pipeline Automation Library](./docs/img/screenshots/ansible-datacenter-00-pipeline-library.png)\n\n### Site Root folder\n\nA root folder for the ansible-datacenter environment can be setup similar to the following.\n![Site Root](./docs/img/screenshots/ansible-datacenter-0-toplevel.png)\n\n### Ansible Vault file credential\n\nSetup the ansible vault file credential to be used by the ansible playbook pipeline and passed into every play.\nIf using the aforementioned [pipeline-automation-library](https://github.com/lj020326/pipeline-automation-lib), make sure the credential ID is 'ansible-vault-pwd-file'.\n![Ansible Vault File Credential](./docs/img/screenshots/ansible-datacenter-0b-secret-file-credential.png)\n\n### Inventory Environment folders\n\nThen setup folders for each environment defined in the inventory similar to the following.\n![Site Environments](./docs/img/screenshots/ansible-datacenter-1a-env-dev.png)\n\n### Jenkins Pipelines to run Ansible tags\n\nEach job folder corresponds to a tag defined in the site.yml playbook.\n![Ansible Tags](./docs/img/screenshots/ansible-datacenter-1aa-tags.png)\n\nTo make setting up each folder consistent and simple as possible, the jobs all are exactly the same except the folder name.\nThe job folders all use the same pipeline definition as seen below.  Using this method, whenever a new ansible tag is created, adding a corresponding jenkins job folder is as easy as copying an existing one and naming it respectively to match the newly created ansible tag. \n![Jenkins Pipeline](./docs/img/screenshots/ansible-datacenter-1b-jenkins-pipeline-definition-ansible-tags.png)\n\n### Ansible Pipeline Parameters\n\nAll jobs use the same 2 parameters for the limit hosts directive and debug.\n![Job Parameters](./docs/img/screenshots/ansible-datacenter-2b-deploy-vm-params.png)\n\n### Run for defined site.yml tags\n\nThe job history for the tag execution is readily/easily viewable.\n![Job Run History](./docs/img/screenshots/ansible-datacenter-4-deploy-cacerts.png)\n\nHere is the bootstraps linux job history.\n![Job Run History](./docs/img/screenshots/ansible-datacenter-3a-bootstrap-linux.png)\n\nSpecify host(s) or leave blank to run across all hosts for the group(s) defined for the play(s) associated with the tag.\n![Job Parameters](./docs/img/screenshots/ansible-datacenter-3b-bootstrap-linux-params.png)\n\nSee the job console for all ansible pipeline input values and play output.\n![Job Parameters](./docs/img/screenshots/ansible-datacenter-3c-bootstrap-linux-console.png)\n\nThe [pipeline job console output](./docs/img/screenshots/ansible-datacenter-3d-bootstrap-linux-console.md).\n\nAnother job just created to bootstrap docker stacks onto machines.\n![Job Run History](./docs/img/screenshots/ansible-datacenter-5-bootstrap-dockerstack.png)\n\n\n## Ansible Role Development Pipelines\n\n### Role Development Root Folder\n\nSetup root folder.\n![Site Environments](./docs/img/screenshots/ansible-datacenter-10-CICD-dev-pipelines.png)\n\n### Role Development Root Folder\n\nSetup jenkins CICD pipeline folders for each repository.\n![Site Environments](./docs/img/screenshots/ansible-datacenter-10-CICD-dev-pipelines2.png)\n\nThe jenkins CICD branch strategy folder is used to automatically pick up the respective branches and merge strategy.\nWe are using a clone of the [public ansible repo here](https://github.com/lj020326/ansible-configvars-examples). \nOnce the pipeline is configured with the repo, jenkins will scan the repo branches for the existance of the Jenkinsfile and then setup the corresponding branch folders used to run ansible for each branch.\n![Site Environments](./docs/img/screenshots/ansible-datacenter-10-CICD-dev-pipelines3.png)\n\n![Site Environments](./docs/img/screenshots/ansible-datacenter-11-CICD-branches.png)\n\n![Site Environments](./docs/img/screenshots/ansible-datacenter-12-CICD-branches-params.png)\n\n![Site Environments](./docs/img/screenshots/ansible-datacenter-13-CICD-branches-console.png)\n\n\n\n## Run tests from ansible control node\n\n```\necho \"foobarpass\" \u003e ~/.vault_pass\nchmod 600 ~/.vault_pass\nansible-playbook report-windows-facts.yml -i inventory/DEV/hosts.yml -t untagged,report-windows-facts --vault-password-file ~/.vault_pass\n```\n\n## Run molecule tests\n\n```shell\n$ git clone https://github.com/lj020326/ansible-datacenter.git\n$ cd ansible-datacenter\n$ export MOLECULE_DISTRO=redhat7-systemd-python\n$ molecule login\n$ molecule --debug test -s bootstrap_linux_package\n$ molecule destroy\n$ MOLECULE_DISTRO=redhat8-systemd-python molecule --debug test -s bootstrap_linux_package\n$ MOLECULE_DISTRO=redhat8-systemd-python molecule login\n$ molecule destroy\n$ MOLECULE_DISTRO=redhat8-systemd-python molecule converge\n$ molecule destroy\n$ MOLECULE_DISTRO=centos8-systemd-python molecule --debug converge\n$ molecule destroy\n$ MOLECULE_DISTRO=ubuntu2204-systemd-python molecule --debug converge\n\n```\n\n### To log into molecule created container\n\n```shell\n$ MOLECULE_DISTRO=redhat8-systemd-python molecule create\n$ MOLECULE_DISTRO=redhat8-systemd-python molecule login\n$ molecule destroy\n```\n\n## Other useful \n\n### To run/debug the VM template create playbook on packer created VM\n\n```shell\n# find the temp dir used for the ansible-local provisioner from the packer log \n$ cd /tmp/packer-provisioner-ansible-local/63b193ab-d1c4-b355-f4cf-9e9153570896\n$ ansible-playbook bootstrap_vm_template.yml --vault-password-file=~/.vault_pass -c local -i vm_template.yml\n```\n\n### To run play on a group\n\n```shell\n$ ansible-playbook site.yml --tags bootstrap --limit dc_os_Ubuntu\n```\n\n### To build ansible control node\n\n```shell\n$ ansible-playbook site.yml --tags bootstrap-ansible --limit admin02\n```\n\n### To build docker images from source repos\nNote: this is performed from jenkins docker build pipeline and not performed directly using ansible unless necessary \nThe docker image build pipeline source is located here [here](https://github.com/lj020326/pipeline-automation-lib/blob/public/vars/buildDockerImage.groovy).\n\n```shell\n$ ansible-playbook site.yml --tags bootstrap-docker-images --limit admin02\n```\n\n### To setup/configure samba server node\nNote: We now use the samba docker container to run the samba server and no longer build on the VM.\n\n```shell\n$ ansible-playbook site.yml --tags docker-samba-node\n```\n\n### To configure samba client node\n\n```shell\n$ ansible-playbook site.yml --tags bootstrap-samba-client\n```\n\n### To setup/configure linux users\n\n```shell\n$ ansible-playbook site.yml --tags bootstrap-user --vault-password-file ~/.vault_pass\n```\n\n### Using run-playbook.sh launch script\n\n```shell\n$ run-playbook.sh site.yml -t bootstrap-docker-stack -l admin01\n$ run-playbook.sh bootstrap-ntp.yml -l testgroup_lnx\n```\n\n### Using run-ansible.sh launch script for jump hosts\n\nUsing the run-ansible.sh script to automatically first install all dependencies then run the command\n\nA [run-ansible.sh script](run-ansible.sh) is available that will upon execution always (1) check and create a virtualenv named 'venv' if not already exists, (2) install [pip library requirements](./requirements.txt), (3) install [collection requirements](collections/requirements.yml), (4) install [role requirements](roles/requirements.yml) and (5) run the command specified.  It also checks in the latest code via git Add/Commit/Push (ACP) before the steps just mentioned.  Finally, it also allows specification of a control/jump host to run the playbook via ssh wrapper.  \n\n```shell\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-ansible-user -l control01\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-ansible-user -l media01\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-docker-stack -l media01\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-linux -l control01\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-linux -l media01\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-mounts -l media01\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-registry -l media01\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-user -l control01\nrun-ansible.sh ansible-playbook -i inventory/PROD/hosts.yml site.yml --tags bootstrap-user -l media01\n\n```\n\n\n### To setup/configure iscsi client node\n\n```shell\n$ ansible-playbook site.yml --tags iscsi-client\n```\n\n## working with openstack deploy node setup\n\n```shell\nansible -i inventory/hosts.yml openstack -m ping\nansible -i inventory/hosts-openstack.ini openstack -m ping\n\nansible-playbook site.yml --tags bootstrap-linux --limit os_linux\nansible-playbook site.yml --tags bootstrap-linux-firewalld --limit vmub2201\nansible-playbook site.yml --tags bootstrap-docker --limit docker\nansible-playbook site.yml --tags bootstrap-network --limit node01\nansible-playbook site.yml --tags bootstrap-openstack\nansible-playbook site.yml --tags bootstrap-openstack-deploy-node\nansible-playbook site.yml --tags bootstrap-user --limit ubuntu18\nansible-playbook site.yml --tags openstack-deploy-node\nansible-playbook site.yml --tags openstack-osclient\n\nkolla-ansible -v -i inventory/hosts-openstack.ini bootstrap-servers\nkolla-ansible -v -i inventory/hosts-openstack.ini prechecks\nkolla-ansible -v -i inventory/hosts-openstack.ini deploy\nkolla-ansible -v -i inventory/hosts-openstack.ini post-deploy\n\n```\n\n\nworking with openstack node cleanup/destroy/reset\n\n```shell\nkolla-ansible -v -i inventory/hosts-openstack.ini destroy\nkolla-ansible -v -i inventory/hosts-openstack.ini destroy --yes-i-really-really-mean-it\n\n```\n\nworking with openstack env setup\n\n```shell\nscripts/kolla-ansible/init-runonce.sh\nansible-playbook site.yml --tags bootstrap-openstack-cloud\nopenstack server create --image cirros --flavor m1.tiny --key-name mykey --network demo-net demo1\n\n```\n\n\n\nOther useful plays\n```shell\nansible-playbook site.yml --tags bootstrap-linux-mounts --limit os_linux\nansible-playbook site.yml --tags bootstrap-linux-mounts --limit dc_os_centos_7\nansible-playbook site.yml --tags bootstrap-linux-mounts --limit postgres\nansible-playbook site.yml --tags bootstrap-linux-mounts --limit media\nansible-playbook site.yml --tags bootstrap-openstack\nansible-playbook site.yml --tags bootstrap-openstack-cloud\nansible-playbook site.yml --tags bootstrap-openstack-deploy-node\n```\n\nOpenstack plays\n```shell\n#ansible-playbook site.yml --tags openstack-deploy-node\nansible-playbook site.yml --tags bootstrap-openstack\nkolla-ansible -i inventory/hosts-openstack.ini bootstrap-servers\nkolla-ansible -i inventory/hosts-openstack.ini prechecks\nkolla-ansible -i inventory/hosts-openstack.ini deploy\n\n## running post-deploy creates the /etc/kolla/openrc.sh\n## ref: https://github.com/lj020326/kolla-ansible/blob/main/ansible/post-deploy.yml\nkolla-ansible -i inventory/hosts-openstack.ini post-deploy\n\n## setup osclient configs if necessary\n## NOTE: not necessary to run this since it is included in bootstrap-openstack-cloud play\n#ansible-playbook site.yml --tags openstack-osclient\n\nopenstack image list\nopenstack service list\nopenstack network list\nopenstack router list\nopenstack server list\nopenstack compute service list\nopenstack dns service list\nopenstack zone list\n\n## if the above works - then can run custom cloud config\nansible-playbook site.yml --tags bootstrap-openstack-cloud\n\n## to reconfigure kolla-ansible configure based on latest changes\nkolla-ansible -i inventory/hosts-openstack.ini reconfigure\n\n## to reconfigure a specific service, e.g., nova, neutron, etc\nkolla-ansible -i inventory/hosts-openstack.ini reconfigure --tags nova\ndocker ps -f name=compute\n\nkolla-ansible -i inventory/hosts-openstack.ini reconfigure --tags neutron\ndocker ps -f name=neutron\n\nkolla-ansible -i inventory/hosts-openstack.ini reconfigure --tags designate\ndocker ps -f name=designate\n\n#openstack zone create --email admin@openstack.example.int openstack.example.int.\nopenstack zone create --email admin@example.int openstack.example.int.\n\n\n## or per (https://ask.openstack.org/en/question/113699/kolla-ansible-how-to-managemodify-configuration-files/)\nkolla-ansible -i inventory/hosts-openstack.ini genconfig ## (and restart manually the containers)\n\n./inventory/openstack_inventory.py --list\n\n## to destroy/reset everything back to the beginning for the inventory:\nkolla-ansible -i inventory/hosts-openstack.ini destroy --yes-i-really-really-mean-it\n\n```\n\nOther useful tests\n\n```shell\nansible -u administrator -e ansible_password=${ANSIBLE_SSH_PASSWORD} -m ping ubuntu18\nansible -v -u administrator -e ansible_password=${ANSIBLE_SSH_PASSWORD} -e ansible_pyth/bin/python3 -i inventory/hosts.yml -m ping ubuntu18\n```\n\n\n```shell\nansible-playbook site.yml --tags display-vars -l control01\nansible-playbook site.yml --tags display-domain-vars -l os_linux\nansible-playbook site.yml --tags display-domain-vars -l nas02\nansible-playbook site.yml --tags display-domain-vars -l control01\nansible all -m debug -a var=groups['ca_domain']\n\nansible-playbook site.yml --tags bootstrap-bind\nansible-playbook site.yml --tags bootstrap-cacerts\nansible-playbook site.yml --tags deploy-cacerts\nansible-playbook site.yml --tags docker-control-node\nansible-playbook site.yml --tags docker-admin-node\nansible-playbook site.yml --tags docker-media-node\ngethist | grep remote | uniq \u003e\u003e ./README.md \n```\n\n\n## Command Line Usage\n\n### Display/Debug any vars\n\n```shell\nansible-config dump\nansible-config dump |grep DEFAULT_MODULE_PATH\n\nansible-inventory --graph output -i inventory/\nansible-inventory --graph output -i inventory/ ntp\nansible-inventory --graph output -i inventory/ ntp_server\nansible-inventory --graph output -i inventory/DEV/\nansible-inventory --graph output -i inventory/PROD/ ntp\nansible-inventory -i inventory/ --graph ntp\nansible-inventory -i inventory/DEV/ --graph ntp\nansible-inventory -i inventory/QA/ --graph output\nansible-inventory -i inventory/PROD/ --graph output group\nansible-inventory -i inventory/PROD/ --graph output ntp\nansible-inventory -i inventory/PROD/ --list ntp\nansible-inventory -i inventory/PROD/ntp.yml --graph output\nansible-inventory -i inventory/DEV/site1.yml --graph output\n\nansible-playbook -i ./inventory display-ntp-servers.yml \nansible-playbook -i ./inventory/ display-ntp-servers.yml\nansible-playbook -i ./inventory/ playbook.yml\nansible-playbook -i ./inventory/dmz display-ntp-servers.yml \nansible-playbook -i ./inventory/internal display-ntp-servers.yml\nansible-playbook -i ./inventory/internal display-ntp-servers.yml \n\nansible all -m debug -a var=groups['ca_domain']\nansible -i inventory/DEV/hosts.yml  windows -m debug -a var=ansible_port\nansible -i inventory/DEV/hosts.yml  windows -m debug -a var=ansible_winrm_transport\nansible -i inventory/DEV/hosts.yml  windows -m debug -a var=ansible_host,ansible_port\n```\n\n\n### Setup and Run the datacenter playbook roles\n\n## Run playbooks\n\nRun site-setup play:\n\n`ansible-playbook site.yml`\n\nRun site-setup play with a tag:\n\n```\nansible-playbook site.yml --tags docker-media-node\n```\n\n\nRun plays for specific configuration needed\n\nTo run ansible commands from ansible/control node:\n\n```shell\nansible -v -m ping\nansible -m ping ubuntu18\n```\n\nRun play for specific node:\n\n```shell\nansible-playbook site.yml --tags display-hostvars --limit admin01\nansible-playbook site.yml --tags install-cacerts --limit media01\n```\n\n\nRun a play for a specific group of nodes:\n\n```shell\nansible-playbook site.yml --tags install-cacerts --limit windows\nansible-playbook site.yml --tags install-cacerts --limit dc_os_ubuntu\nansible-playbook site.yml -t display-hostvars -l dc_os_centos\nansible-playbook site.yml -t display-hostvars -l docker\n```\n\nE.g., Run site setup play on control node with a tag from windows/msys shell.\n\n```\nansible-playbook site.yml --tags bootstrap-ansible\nansible-playbook site.yml --tags bootstrap-bind\nansible-playbook site.yml --tags bootstrap-cacert\nansible-playbook site.yml --tags bootstrap-caroot\nansible-playbook site.yml --tags bootstrap-cicd\nansible-playbook site.yml --tags bootstrap-docker-stack\nansible-playbook site.yml --tags bootstrap-idrac\nansible-playbook site.yml --tags bootstrap-jenkins-agent\nansible-playbook site.yml --tags bootstrap-keyring\nansible-playbook site.yml --tags bootstrap-kvm\nansible-playbook site.yml --tags bootstrap-ldap-client\nansible-playbook site.yml --tags bootstrap-linux\nansible-playbook site.yml --tags bootstrap-linux-core\nansible-playbook site.yml --tags bootstrap-docker\nansible-playbook site.yml --tags bootstrap-linux-firewalld\nansible-playbook site.yml --tags configure-linux-firewall\nansible-playbook site.yml --tags bootstrap-mergerfs\nansible-playbook site.yml --tags bootstrap-ntp\nansible-playbook site.yml --tags bootstrap-openstack\nansible-playbook site.yml --tags bootstrap-openstack-cloud\nansible-playbook site.yml --tags bootstrap-postfix\nansible-playbook site.yml --tags bootstrap-proxmox\nansible-playbook site.yml --tags bootstrap-stepcli\nansible-playbook site.yml --tags bootstrap-user\nansible-playbook site.yml --tags bootstrap-vmware-esxi\nansible-playbook site.yml --tags build-docker-images\nansible-playbook site.yml --tags deploy-cacerts\nansible-playbook site.yml --tags deploy-vm\nansible-playbook site.yml --tags deploy-vsphere-dc\nansible-playbook site.yml --tags display-hostvars\nansible-playbook site.yml --tags docker-admin-node\nansible-playbook site.yml --tags docker-control-node\nansible-playbook site.yml --tags docker-media-node\nansible-playbook site.yml --tags docker-samba-node\nansible-playbook site.yml --tags deploy-nfs-service\nansible-playbook site.yml --tags vmware-remount-datastores\nansible-playbook site.yml --tags upgrade-vmware-esxi\n```\n\nSetup vsphere dc\n```shell\nansible-playbook site.yml --tags deploy-vsphere-dc\n```\n\nDeploy VMs\n```shell\nansible-playbook site.yml --tags deploy-vm\n```\n\nBootstrap VM nodes if needed\nNote: This is not used any longer since this is now performed from the jenkins pipeline.\nThe jenkins pipeline is responsible for building VM template images using packer.\nThe vm image build pipeline source is located here [here](https://github.com/lj020326/pipeline-automation-lib/blob/public/vars/buildVmTemplate.groovy).\n\n```shell\nansible-playbook site.yml --tags bootstrap-linux --limit admin02\n```\n\nBootstrap node network config *should not be necessary since this is mostly done in deploy-vm\n```shell\nansible-playbook site.yml --tags bootstrap-network --limit node01\n```\n\nDocker stack plays\n```shell\nansible-playbook site.yml --tags docker-admin-node\nansible-playbook site.yml --tags docker-media-node\n```\n\nUseful `site.yml` tag based plays to build/update/configure datacenter:\n\n```shell\nansible-playbook site.yml --tags bootstrap-bind\nansible-playbook site.yml --tags bootstrap-docker\nansible-playbook site.yml --tags bootstrap-linux-core\nansible-playbook site.yml --tags bootstrap-docker\nansible-playbook site.yml --tags bootstrap-linux-firewalld\nansible-playbook site.yml --tags bootstrap-openstack\nansible-playbook site.yml --tags bootstrap-openstack-cloud\nansible-playbook site.yml --tags bootstrap-user\nansible-playbook site.yml --tags bootstrap-vmware-esxi\nansible-playbook site.yml --tags build-docker-images\nansible-playbook site.yml --tags cacerts-deploy\nansible-playbook site.yml --tags deploy-vm\nansible-playbook site.yml --tags deploy-vsphere-dc\nansible-playbook site.yml --tags display-hostvars\nansible-playbook site.yml --tags docker-admin-node\nansible-playbook site.yml --tags docker-media-node\nansible-playbook site.yml --tags fetch-osimages\nansible-playbook site.yml --tags iscsi-client\nansible-playbook site.yml --tags nfs-service\nansible-playbook site.yml --tags vmware-remount-datastores\nansible-playbook site.yml --tags upgrade-vmware-esxi\n```\n\nExample inventory checks\n```shell\nansible -v all --list-hosts\nansible -i ./inventory/PROD/hosts.yml -m debug -a var=cacert_keystore_host admin03\nansible -i ./inventory/PROD/hosts.yml -m debug -a var=jenkins_swarm_agent_controller admin01\nansible -i ./inventory/PROD/hosts.yml -m debug -a var=jenkins_swarm_agent_labels admin01\nansible -i ./inventory/PROD/hosts.yml -m debug -a var=jenkins_swarm_agent_controller admin01\nansible -i inventory/ -m debug -a var=service_route_internal_root_domain vcontrol01\nansible -i inventory/ -m debug -a var=ca_domain vcontrol01\nansible -i inventory/ -m debug -a var=service_route_internal_root_domain vcontrol01\nansible -i inventory/hosts.yml -m debug -a var=ca_domain vcontrol01\nansible -i inventory/hosts.yml -m debug -a var=group_names admin01\nansible -i inventory/hosts.yml -m debug -a var=internal_root_domain vcontrol01\nansible -i inventory/hosts.yml -m debug -a var=jenkins_swarm_agent_controller admin01\nansible -i inventory/hosts.yml -m debug -a var=service_route_internal_root_domain vcontrol01\nansible -i inventory/PROD/ -m debug -a var=ansible_host vcenter7\nansible -i inventory/PROD/ -m debug -a var=bootstrap_docker__script_dirs admin03\nansible -i inventory/PROD/ -m debug -a var=bootstrap_docker__swarm_managers admin03\nansible -i inventory/PROD/ -m debug -a var=bootstrap_docker__swarm_remote_addrs admin03\nansible -i inventory/PROD/ -m debug -a var=ca_domain admin01\nansible -i inventory/PROD/ -m debug -a var=ca_domain vcontrol01\nansible -i inventory/PROD/ -m debug -a var=docker_stack_internal_domain admin03\nansible -i inventory/PROD/ -m debug -a var=docker_stack_internal_root_domain admin03\nansible -i inventory/PROD/ -m debug -a var=group_names admin01\nansible -i inventory/PROD/ -m debug -a var=group_names vcenter7\nansible -i inventory/PROD/ -m debug -a var=group_names vcontrol01\nansible -i inventory/PROD/ -m debug -a var=internal_domain vcenter7\nansible -i inventory/PROD/ -m debug -a var=internal_domain vcontrol01\nansible -i inventory/PROD/ -m debug -a var=internal_root_domain vcenter7\nansible -i inventory/PROD/ -m debug -a var=internal_subdomain vcontrol01\nansible -i inventory/PROD/ -m debug -a var=service_route_internal_root_domain admin01\nansible -i inventory/PROD/hosts.yml -m debug -a var=jenkins_swarm_agent_controller admin01\nansible-inventory --help\nansible-inventory -h\nansible-inventory -i ./inventory/PROD/hosts.yml --graph \nansible-inventory -i inventory/PROD/ --graph vmware_vcenter\n```\n\nExample test playbook runs\n```shell\nrunme.sh site.yml -t deploy-cacerts -l admin01\nrunme.sh bootstrap-pip.yml -l admin01\nrunme.sh -vvv bootstrap-docker.yml -l admin01\nrunme.sh bootstrap-docker-stack.yml -l docker_stack_jenkins_jcac\nrunme.sh bootstrap-jenkins-agent.yml -l admin01\n```\n\n## Contact\n\n[![Linkedin](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white)](https://www.linkedin.com/in/leejjohnson/)\n\n## Reference\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flj020326%2Fansible-datacenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flj020326%2Fansible-datacenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flj020326%2Fansible-datacenter/lists"}