├── .travis.yml ├── LICENSE ├── README.md ├── Vagrantfile ├── defaults └── main.yml ├── files ├── background.jpg └── cmdb_schema.sql ├── handlers └── main.yml ├── meta └── main.yml ├── playbook.yml ├── playbooks ├── create_host_groups_inventory.yml ├── db_exports │ └── 1_export_groups_hosts_from_db.yml ├── db_imports │ ├── 1_create_host_groups_inventory.yml │ ├── 2_import_db_inventory_to_sqlite.yml │ ├── add_host_details_to_db.yml │ ├── create_db_hostdetails.sql.j2 │ └── create_db_inventory_list.yml.j2 ├── db_inventory_list.yml.j2 ├── generate_db_inventory.yml └── import_db_inventory_to_sqlite.yml ├── provision.sh ├── requirements.yml ├── screenshots ├── Ansible_Group_Actions.png ├── Ansible_Host_details.png └── Jenkins_Integration.png ├── tasks ├── config_apache2_pages.yml ├── config_php5_apache2.yml ├── config_sqlite.yml ├── debian.yml └── main.yml ├── templates ├── etc │ └── php5 │ │ └── apache2 │ │ └── php.ini.j2 └── var │ └── www │ └── html │ ├── add_group_contact.html.j2 │ ├── add_group_contact.php.j2 │ ├── add_group_host.html.j2 │ ├── add_group_host.php.j2 │ ├── add_groups.html.j2 │ ├── add_groups.php.j2 │ ├── add_user_links.php.j2 │ ├── ansible_actions.html.j2 │ ├── ansible_actions.php.j2 │ ├── ansible_test_jenkins_job.php.j2 │ ├── calendar.php.j2 │ ├── common.php.j2 │ ├── common_base.php.j2 │ ├── configure_user_jenkins_api.php.j2 │ ├── create_user.html.j2 │ ├── create_user.php.j2 │ ├── delete_group.html.j2 │ ├── delete_group.php.j2 │ ├── delete_group_contact.php.j2 │ ├── delete_group_host.html.j2 │ ├── delete_group_host.php.j2 │ ├── edit_group.html.j2 │ ├── edit_group.php.j2 │ ├── edit_group_contact.html.j2 │ ├── edit_group_contact.php.j2 │ ├── edit_user_info.php.j2 │ ├── edit_user_jenkins_api.php.j2 │ ├── group_actions.php.j2 │ ├── index.html.j2 │ ├── index.php.j2 │ ├── login.php.j2 │ ├── logout.php.j2 │ ├── members.php.j2 │ ├── php_details.php.j2 │ ├── query_group.php.j2 │ ├── query_group_contact_info.php.j2 │ ├── query_group_details.php.j2 │ ├── query_group_hosts.php.j2 │ ├── query_host_details.php.j2 │ ├── query_users.php.j2 │ ├── register_user.php.j2 │ ├── run_group_ansible_playbook.php.j2 │ ├── send_group_email.html.j2 │ ├── send_group_email.php.j2 │ ├── validate_login.php.j2 │ ├── view_group_contact_info.php.j2 │ ├── view_user_jenkins_api.php.j2 │ └── view_user_links.php.j2 ├── tests ├── inventory └── test.yml └── vars └── main.yml /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | 5 | # Use the new container infrastructure 6 | sudo: false 7 | 8 | # Install ansible 9 | addons: 10 | apt: 11 | packages: 12 | - python-pip 13 | 14 | install: 15 | # Install ansible 16 | - pip install ansible 17 | 18 | # Check ansible version 19 | - ansible --version 20 | 21 | # Create ansible.cfg with correct roles_path 22 | - printf '[defaults]\nroles_path=../' >ansible.cfg 23 | 24 | script: 25 | # Basic role syntax check 26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check 27 | 28 | notifications: 29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Information 2 | =========== 3 | 4 | This is a project that I started about 6-7 months ago. I worked on it for a bit and put it down. 5 | The intention of this was to turn into an Ansible Tower alternative with a ton of options. Allowing 6 | for back-end components to be pluggable. Jenkins integration, ELKStack, PowerDNS, PHPipam, VMWare, 7 | OpenStack and so much more. I initially built this around a simple SQLite DB but planned on porting 8 | to MySQL. I wrote all of the PHP code for the pages and etc. So yeah...a lot of work needed there. 9 | 10 | So I have decided to put this out here in hopes that maybe someone may have a need for something 11 | like this and/or contribute to this and push it along as an open-source project. Then again 12 | it may not be of any use but in any case. I am putting it out here. Feel free to contribute as you 13 | see fit. 14 | 15 | I had huge plans for this but honestly for one person it was a lot to take on and I have been 16 | sitting on this code for months and figured it was time to open this up to anyone and everyone 17 | and see what we can come up with. 18 | 19 | Enjoy! 20 | 21 | Usage 22 | ----- 23 | ###### Vagrant 24 | You can spin this up in a Vagrant environment easily for testing and hacking. 25 | ```` 26 | vagrant up 27 | ```` 28 | Once deployed open your browser of choice and browse to http://127.0.0.1:8080 29 | 30 | There is not a default login so you will need to click register at the bottom left 31 | of the page. Enter your details and then submit and login with the username/password 32 | you registered with. This registration is in no way sent anywhere. It is purely 33 | written to the DB and then a lookup is done to the DB for logins. (This obviously 34 | needs work). 35 | 36 | There are many playbooks to utilize within the playbooks directory. You can generate 37 | host groups and inventory with details about hosts which are discovered via ansible 38 | facts. Those facts can be imported into the DB and then will show up in the WebUI. 39 | Once those fields are populated you can then import playbooks and etc. to run against 40 | a group of hosts or a single host. Lot's of options...Many are not complete. 41 | 42 | Contributing 43 | ------------ 44 | Highly encouraged. Fork this project. Hack away at it. Submit a PR and let's keep 45 | this project going. 46 | 47 | Screenshots 48 | ----------- 49 | ![alt text](screenshots/Jenkins_Integration.png "Jenkins Integration") 50 | 51 | ![alt text](screenshots/Ansible_Group_Actions.png "Ansible Group Actions") 52 | 53 | ![alt text](screenshots/Ansible_Host_details.png "Ansible Host Details") 54 | 55 | License 56 | ------- 57 | 58 | Apache 2.0 59 | 60 | Author Information 61 | ------------------ 62 | 63 | Larry Smith Jr. 64 | - @mrlesmithjr 65 | - http://everythingshouldbevirtual.com 66 | - mrlesmithjr [at] gmail.com 67 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure(2) do |config| 9 | config.vm.define "cmdb" do |cmdb| 10 | cmdb.vm.box = "mrlesmithjr/trusty64" 11 | cmdb.vm.hostname = "cmdb" 12 | 13 | cmdb.vm.network :private_network, ip: "192.168.202.201" 14 | cmdb.vm.network "forwarded_port", guest: 80, host: 8080 15 | 16 | cmdb.vm.provider "virtualbox" do |vb| 17 | vb.memory = "1024" 18 | end 19 | end 20 | config.vm.provision :shell, path: "provision.sh", keep_color: "true" 21 | end 22 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | allow_www_data_sudo: false 3 | apache2_root: /var/www/html 4 | cmdb_notifications_from_email: '{{ infra_email_notifications }}' 5 | cmdb_notifications_from_email_address: '{{ infra_email_notifications }}' 6 | cmdb_sqlite_db_file: '{{ cmdb_sqlite_db_path }}/cmdb.db' 7 | cmdb_sqlite_db_path: '{{ apache2_root }}/../db' 8 | cmdb_web_author: '{{ pri_domain_name }}' 9 | cmdb_web_body: '{{ pri_domain_name }} - CMDB' 10 | cmdb_web_description: 'One Stop Portal for All THINGS DevOps' 11 | cmdb_web_group: www-data 12 | cmdb_web_keywords: 'Jenkins, Rundeck, Ansible, CMDB, Logstash, ELK, PHPIpam, DDI, DNS, DevOps' 13 | cmdb_web_links: 14 | - name: 'DDI - NSEdit' 15 | url: 'http://{{ ipam_server_fqdn }}/nsedit' 16 | - name: 'DDI - PHPIpam' 17 | url: 'http://{{ ipam_server_fqdn }}/phpipam' 18 | - name: 'ELK Stack - ES Cluster Status' 19 | url: 'http://{{ logstash_server_fqdn }}:9200/_plugin/HQ' 20 | - name: 'ELK Stack - HAProxy Stats' 21 | url: 'http://{{ logstash_server_fqdn }}:9090' 22 | - name: 'ELK Stack - Logstash' 23 | url: 'http://{{ logstash_server_fqdn }}' 24 | - name: Gitlab 25 | url: 'http://{{ gitlab_server_fqdn }}' 26 | - name: 'Jenkins - CI' 27 | url: 'http://{{ jenkins_server_fqdn }}:8080' 28 | - name: Jira 29 | url: 'http://{{ jira_server_fqdn }}:8080' 30 | - name: 'RANCID - NCM - Network Configs' 31 | url: 'http://{{ gitlab_server_fqdn}}/rancid/rancid/tree/master' 32 | - name: 'Rundeck - CI' 33 | url: 'http://{{ rundeck_server_fqdn }}:4440' 34 | - name: 'Sensu - Monitoring' 35 | url: 'http://sensu.{{ pri_domain_name }}:3000' 36 | - name: 'PHP Server Info' 37 | url: 'php_details.php' 38 | cmdb_web_title: '{{ pri_domain_name }} - CMDB' 39 | cmdb_web_user: www-data 40 | enable_php_syslog: false 41 | gitlab_server_fqdn: 'gitlab.{{ pri_domain_name }}' 42 | infra_email_notifications: 'infrastructure@{{ pri_domain_name }}' 43 | install_ansible: true 44 | install_php_sqlite: true 45 | install_php: true 46 | ipam_server_fqdn: 'ipam.{{ pri_domain_name }}' 47 | jenkins_api_token: 4758714d940c7a5c9dc2e7dbd00310e6 48 | jenkins_server_fqdn: 'jenkins.{{ pri_domain_name }}' 49 | jira_server_fqdn: 'jira.{{ pri_domain_name }}' 50 | logstash_server_fqdn: 'logstash.{{ pri_domain_name }}' 51 | php_sendmail_path: '/usr/sbin/sendmail -t -i' 52 | pri_domain_name: 'example.org' 53 | rundeck_server_fqdn: 'rundeck.{{ pri_domain_name }}' 54 | -------------------------------------------------------------------------------- /files/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrlesmithjr/ansible-cmdb/ab2a0d1eb09223d5c6754925623c39d36917803c/files/background.jpg -------------------------------------------------------------------------------- /files/cmdb_schema.sql: -------------------------------------------------------------------------------- 1 | BEGIN TRANSACTION; 2 | CREATE TABLE IF NOT EXISTS "AnsiblePlaybooks" ( 3 | `Id` INTEGER PRIMARY KEY AUTOINCREMENT, 4 | `Name` TEXT, 5 | `Description` TEXT, 6 | `Path` TEXT, 7 | UNIQUE (Name,Path) 8 | ); 9 | CREATE TABLE IF NOT EXISTS "Hosts" ( 10 | `HostId` INTEGER PRIMARY KEY AUTOINCREMENT, 11 | `HostName` TEXT NOT NULL UNIQUE, 12 | `HostDescription` TEXT, 13 | `HostCreatedOn` TEXT, 14 | `LastUpdateTime` TEXT 15 | ); 16 | CREATE TABLE IF NOT EXISTS "HostDetails" ( 17 | `HostDetailsId` INTEGER PRIMARY KEY AUTOINCREMENT, 18 | `HostArchitecture` TEXT, 19 | `HostBIOSDate` TEXT, 20 | `HostBIOSVersion` TEXT, 21 | `HostDistribution` TEXT, 22 | `HostDistributionRelease` TEXT, 23 | `HostDistributionVersion` TEXT, 24 | `HostFQDN` TEXT, 25 | `HostHardDrive` TEXT, 26 | `HostHardDrivePartions` TEXT, 27 | `HostHardDriveSize` TEXT, 28 | `HostInterface` TEXT, 29 | `HostInterfaceAddress` TEXT, 30 | `HostInterfaceGateway` TEXT, 31 | `HostInterfaceMAC` TEXT, 32 | `HostInterfaceNetmask` TEXT, 33 | `HostInterfaces` TEXT, 34 | `HostKernel` TEXT, 35 | `HostMemFreeMB` INTEGER, 36 | `HostMemTotalMB` INTEGER, 37 | `HostMounts` TEXT, 38 | `HostOSFamily` TEXT, 39 | `HostProcessor` TEXT, 40 | `HostProcessorCores` INTEGER, 41 | `HostProcessorCount` INTEGER, 42 | `HostProductName` TEXT, 43 | `HostSwapFree` INTEGER, 44 | `HostSwapTotal` INTEGER, 45 | `HostSystemVendor` TEXT, 46 | `HostTimeZone` TEXT, 47 | `HostVirtualizationType` TEXT, 48 | `LastUpdateTime` TEXT, 49 | `HostId` INTEGER, 50 | FOREIGN KEY(`HostId`) REFERENCES Hosts ( HostId ) ON DELETE CASCADE ON UPDATE CASCADE, 51 | UNIQUE (HostId,HostFQDN) 52 | ); 53 | CREATE TABLE IF NOT EXISTS "Groups" ( 54 | `GroupId` INTEGER PRIMARY KEY AUTOINCREMENT, 55 | `GroupName` TEXT NOT NULL UNIQUE, 56 | `GroupDescription` TEXT, 57 | `GroupDTAP` CHAR(1) NOT NULL, 58 | `GroupCreatedOn` TEXT, 59 | `LastUpdateTime` TEXT 60 | ); 61 | CREATE TABLE IF NOT EXISTS "GroupVars" ( 62 | `VarsId` INTEGER PRIMARY KEY AUTOINCREMENT, 63 | `VarName` TEXT NOT NULL UNIQUE, 64 | `VarDescription` TEXT, 65 | `VarReference` TEXT NOT NULL, 66 | `VarSet` TEXT NOT NULL, 67 | `VarValue` TEXT NOT NULL, 68 | `LastUpdateTime` TEXT, 69 | `GroupId` INTEGER NOT NULL, 70 | FOREIGN KEY(`GroupId`) REFERENCES Groups ( GroupId ) ON DELETE CASCADE ON UPDATE CASCADE 71 | ); 72 | CREATE TABLE IF NOT EXISTS "GroupContact" ( 73 | `ContactId` INTEGER PRIMARY KEY AUTOINCREMENT, 74 | `ContactName` TEXT NOT NULL, 75 | `ContactEmail` TEXT NOT NULL, 76 | `ContactPhone` TEXT NOT NULL, 77 | `ContactCreatedOn` TEXT, 78 | `LastUpdateTime` TEXT, 79 | `GroupId` INTEGER NOT NULL, 80 | FOREIGN KEY(`GroupId`) REFERENCES Groups ( GroupId ) ON DELETE CASCADE ON UPDATE CASCADE, 81 | UNIQUE (ContactName,ContactEmail) 82 | ); 83 | CREATE TABLE IF NOT EXISTS "HostGroups" ( 84 | `HostGroupId` INTEGER PRIMARY KEY AUTOINCREMENT, 85 | `GroupId` INTEGER NOT NULL, 86 | `GroupName` TEXT NOT NULL, 87 | `HostId` INTEGER NOT NULL, 88 | `HostName` TEXT NOT NULL, 89 | FOREIGN KEY(`GroupId`) REFERENCES Groups (GroupId) ON DELETE CASCADE ON UPDATE CASCADE, 90 | FOREIGN KEY(`HostId`) REFERENCES Hosts ( HostId ) ON DELETE CASCADE ON UPDATE CASCADE, 91 | UNIQUE (GroupId,HostId) 92 | ); 93 | CREATE TABLE IF NOT EXISTS "LoginAttempts" ( 94 | `Id` INTEGER PRIMARY KEY AUTOINCREMENT, 95 | `UserId` INTEGER NOT NULL, 96 | `Time` TEXT NOT NULL 97 | ); 98 | CREATE TABLE IF NOT EXISTS "Users" ( 99 | `UserId` INTEGER PRIMARY KEY AUTOINCREMENT, 100 | `Email` TEXT NOT NULL, 101 | `FirstName` TEXT NOT NULL, 102 | `LastName` TEXT NOT NULL, 103 | `Password` CHAR(128) NOT NULL, 104 | `Phone` TEXT, 105 | `Role` TEXT NOT NULL DEFAULT 'user', 106 | `Salt` CHAR(128), 107 | `UserName` TEXT NOT NULL, 108 | UNIQUE (UserName,Email) 109 | ); 110 | CREATE TABLE IF NOT EXISTS "UsersExtAPILinks" ( 111 | `Id` INTEGER PRIMARY KEY AUTOINCREMENT, 112 | `APIToken` TEXT, 113 | `JenkinsURL` TEXT, 114 | `JenkinsAPITokenUserId` TEXT, 115 | `JenkinsUserAPIToken` TEXT, 116 | `Name` TEXT, 117 | `Url` TEXT, 118 | `UserId` INTEGER NOT NULL, 119 | FOREIGN KEY ('UserId') REFERENCES Users (UserId) ON DELETE CASCADE ON UPDATE CASCADE, 120 | UNIQUE (UserId,Name,Url,APIToken), 121 | UNIQUE (UserId,JenkinsURL,JenkinsAPITokenUserId,JenkinsUserAPIToken) 122 | ); 123 | CREATE TABLE IF NOT EXISTS "UsersLinks" ( 124 | `Id` INTEGER PRIMARY KEY AUTOINCREMENT, 125 | `Name` TEXT NOT NULL, 126 | `Url` TEXT NOT NULL, 127 | `UserId` INTEGER NOT NULL, 128 | FOREIGN KEY(`UserId`) REFERENCES Users (UserId) ON DELETE CASCADE ON UPDATE CASCADE, 129 | UNIQUE (UserId,Name,Url) 130 | ); 131 | CREATE TABLE IF NOT EXISTS "GroupContactLog" ( 132 | `Id` INTEGER PRIMARY KEY AUTOINCREMENT, 133 | `OldContactName` TEXT, 134 | `NewContactName` TEXT, 135 | `OldContactEmail` TEXT, 136 | `NewContactEmail` TEXT, 137 | `OldContactPhone` TEXT, 138 | `NewContactPhone` TEXT, 139 | `Date` TEXT 140 | ); 141 | CREATE TABLE IF NOT EXISTS "GroupVarsLog" ( 142 | `Id` INTEGER PRIMARY KEY AUTOINCREMENT, 143 | `OldVarName` TEXT, 144 | `NewVarName` TEXT, 145 | `OldVarDescription` TEXT, 146 | `NewVarDescription` TEXT, 147 | `OldVarReference` TEXT, 148 | `NewVarReference` TEXT, 149 | `OldVarSet` TEXT, 150 | `NewVarSet` TEXT, 151 | `OldVarValue` TEXT, 152 | `NewVarValue` TEXT, 153 | `Date` TEXT 154 | ); 155 | CREATE TABLE IF NOT EXISTS "GroupsLog" ( 156 | `Id` INTEGER PRIMARY KEY AUTOINCREMENT, 157 | `OldGroupName` TEXT, 158 | `NewGroupName` TEXT, 159 | `OldGroupDescription` TEXT, 160 | `NewGroupDescription` TEXT, 161 | `Date` TEXT 162 | ); 163 | CREATE TRIGGER IF NOT EXISTS GroupContactUpdated UPDATE OF ContactName ON GroupContact 164 | BEGIN 165 | INSERT INTO GroupContactLog(OldContactName, NewContactName, Date) VALUES (old.ContactName, New.ContactName, datetime('now')); 166 | END; 167 | COMMIT; 168 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for ansible-cmdb 3 | - name: restart apache2 4 | service: name=apache2 state=restarted 5 | 6 | - name: reload apache2 7 | service: name=apache2 state=reloaded 8 | 9 | - name: reload ferm 10 | shell: service ferm force-reload 11 | 12 | - name: run ferm 13 | shell: ferm /etc/ferm/ferm.conf 14 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Some suggested licenses: 11 | # - BSD (default) 12 | # - MIT 13 | # - GPLv2 14 | # - GPLv3 15 | # - Apache 16 | # - CC-BY 17 | license: license (GPLv2, CC-BY, etc) 18 | 19 | min_ansible_version: 1.2 20 | 21 | # Optionally specify the branch Galaxy will use when accessing the GitHub 22 | # repo for this role. During role install, if no tags are available, 23 | # Galaxy will use this branch. During import Galaxy will access files on 24 | # this branch. If travis integration is cofigured, only notification for this 25 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 26 | # (usually master) will be used. 27 | #github_branch: 28 | 29 | # 30 | # Below are all platforms currently available. Just uncomment 31 | # the ones that apply to your role. If you don't see your 32 | # platform on this list, let us know and we'll get it added! 33 | # 34 | #platforms: 35 | #- name: EL 36 | # versions: 37 | # - all 38 | # - 5 39 | # - 6 40 | # - 7 41 | #- name: GenericUNIX 42 | # versions: 43 | # - all 44 | # - any 45 | #- name: Solaris 46 | # versions: 47 | # - all 48 | # - 10 49 | # - 11.0 50 | # - 11.1 51 | # - 11.2 52 | # - 11.3 53 | #- name: Fedora 54 | # versions: 55 | # - all 56 | # - 16 57 | # - 17 58 | # - 18 59 | # - 19 60 | # - 20 61 | # - 21 62 | # - 22 63 | #- name: Windows 64 | # versions: 65 | # - all 66 | # - 2012R2 67 | #- name: SmartOS 68 | # versions: 69 | # - all 70 | # - any 71 | #- name: opensuse 72 | # versions: 73 | # - all 74 | # - 12.1 75 | # - 12.2 76 | # - 12.3 77 | # - 13.1 78 | # - 13.2 79 | #- name: Amazon 80 | # versions: 81 | # - all 82 | # - 2013.03 83 | # - 2013.09 84 | #- name: GenericBSD 85 | # versions: 86 | # - all 87 | # - any 88 | #- name: FreeBSD 89 | # versions: 90 | # - all 91 | # - 8.0 92 | # - 8.1 93 | # - 8.2 94 | # - 8.3 95 | # - 8.4 96 | # - 9.0 97 | # - 9.1 98 | # - 9.1 99 | # - 9.2 100 | #- name: Ubuntu 101 | # versions: 102 | # - all 103 | # - lucid 104 | # - maverick 105 | # - natty 106 | # - oneiric 107 | # - precise 108 | # - quantal 109 | # - raring 110 | # - saucy 111 | # - trusty 112 | # - utopic 113 | # - vivid 114 | #- name: SLES 115 | # versions: 116 | # - all 117 | # - 10SP3 118 | # - 10SP4 119 | # - 11 120 | # - 11SP1 121 | # - 11SP2 122 | # - 11SP3 123 | #- name: GenericLinux 124 | # versions: 125 | # - all 126 | # - any 127 | #- name: Debian 128 | # versions: 129 | # - all 130 | # - etch 131 | # - jessie 132 | # - lenny 133 | # - squeeze 134 | # - wheezy 135 | 136 | galaxy_tags: [] 137 | # List tags for your role here, one per line. A tag is 138 | # a keyword that describes and categorizes the role. 139 | # Users find roles by searching for tags. Be sure to 140 | # remove the '[]' above if you add tags to this list. 141 | # 142 | # NOTE: A tag is limited to a single word comprised of 143 | # alphanumeric characters. Maximum 20 tags per role. 144 | 145 | dependencies: [] 146 | # List your role dependencies here, one per line. 147 | # Be sure to remove the '[]' above if you add dependencies 148 | # to this list. -------------------------------------------------------------------------------- /playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | become: true 4 | vars: 5 | - install_ansible: false #set to false for Vagrant environment...Ansible is already installed. 6 | roles: 7 | - role: ansible-postfix 8 | - role: ansible-timezone 9 | - role: ansible-apache2 10 | - role: ansible-cmdb 11 | -------------------------------------------------------------------------------- /playbooks/create_host_groups_inventory.yml: -------------------------------------------------------------------------------- 1 | - hosts: all 2 | sudo: true 3 | remote_user: remote 4 | vars: 5 | - db_inventory_dir: ./db_inventory 6 | - db_inventory_file: ./db_inventory.yml 7 | tasks: 8 | - name: creating db_inventory_dir 9 | file: path="{{ db_inventory_dir }}" state=directory 10 | delegate_to: localhost 11 | run_once: true 12 | sudo: false 13 | 14 | - name: removing existing inventory files 15 | file: path="{{ item }}" state=absent 16 | delegate_to: localhost 17 | with_items: 18 | - "{{ db_inventory_dir }}/{{ ansible_hostname }}.yml" 19 | - "{{ db_inventory_file }}" 20 | 21 | - name: creating yaml list of groups/hosts 22 | template: src=db_inventory_list.yml.j2 dest="{{ db_inventory_dir }}/{{ ansible_hostname }}.yml" 23 | delegate_to: localhost 24 | sudo: false 25 | 26 | - name: merging all host inventory groups into one 27 | assemble: src="{{ db_inventory_dir }}/" dest="{{ db_inventory_file }}" 28 | delegate_to: localhost 29 | run_once: true 30 | sudo: false 31 | 32 | - name: adding list var to inventory file 33 | lineinfile: dest="{{ db_inventory_file }}" regexp="^host_groups" line="host_groups{{ ':' }}" insertbefore=BOF 34 | delegate_to: localhost 35 | run_once: true 36 | sudo: false 37 | 38 | - name: adding yaml formatting to inventory file 39 | lineinfile: dest="{{ db_inventory_file }}" regexp="^---" line="---" insertbefore=BOF 40 | delegate_to: localhost 41 | run_once: true 42 | sudo: false 43 | 44 | - name: chmodding inventory file 45 | file: path="{{ db_inventory_file }}" mode=0775 46 | delegate_to: localhost 47 | run_once: true 48 | -------------------------------------------------------------------------------- /playbooks/db_exports/1_export_groups_hosts_from_db.yml: -------------------------------------------------------------------------------- 1 | --- 2 | #### Exports Groups and Hosts from DB and dumps to an inventory file for use with Ansible.. 3 | #### Associcates the hosts with their proper groups. 4 | - hosts: localhost 5 | sudo: true 6 | remote_user: remote 7 | vars: 8 | - apache2_root: /var/www/html 9 | - cmdb_sqlite_db_file: '{{ cmdb_sqlite_db_path }}/cmdb.db' 10 | - cmdb_sqlite_db_path: '{{ apache2_root }}/../db' 11 | - create_inventory_file: ./hosts 12 | - db_groups_export_file: ./groups.yml 13 | tasks: 14 | - name: exporting groups from db 15 | shell: "sqlite3 {{ cmdb_sqlite_db_file }} \"SELECT GroupName FROM HostGroups GROUP BY GroupName;\"" 16 | register: db_groups 17 | delegate_to: cmdb 18 | 19 | - name: query hosts per group 20 | shell: "sqlite3 {{ cmdb_sqlite_db_file }} \"SELECT HostName FROM HostGroups WHERE GroupName='{{ item }}';\"" 21 | delegate_to: cmdb 22 | register: db_hosts 23 | with_items: db_groups.stdout_lines 24 | 25 | - name: checking for existing inventory file 26 | stat: path="{{ create_inventory_file }}" 27 | register: inv_file_check 28 | 29 | - name: creating inventory file when missing 30 | file: path="{{ create_inventory_file }}" state=touch 31 | sudo: false 32 | when: not inv_file_check.stat.exists 33 | 34 | - name: creating usable Ansible inventory 35 | sudo: false 36 | lineinfile: dest="{{ create_inventory_file }}" line="[{{ item.item }}]{{ '\n' }}{{ item.stdout }}{{ '\n' }}" 37 | with_items: db_hosts.results 38 | -------------------------------------------------------------------------------- /playbooks/db_imports/1_create_host_groups_inventory.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ### Takes an Ansible Inventory file and exports to a usable yaml file to be used by 2_import_db_inventory_to_sqlite.yml 3 | ### ansible-playbook -i hosts 1_create_host_groups_inventory.yml 4 | - hosts: all 5 | sudo: true 6 | remote_user: remote 7 | vars: 8 | - cmdb_web_group: www-data 9 | - cmdb_web_user: www-data 10 | - db_hostvars_dir: ./db_hostvars 11 | - db_hostvars_file: ./db_hostvars.sql 12 | - db_inventory_dir: ./db_inventory 13 | - db_inventory_file: ./db_inventory.yml 14 | tasks: 15 | - name: creating folders 16 | file: path="{{ item }}" state=directory 17 | delegate_to: localhost 18 | run_once: true 19 | sudo: false 20 | with_items: 21 | - "{{ db_hostvars_dir }}" 22 | - "{{ db_inventory_dir }}" 23 | 24 | - name: removing existing files 25 | file: path="{{ item }}" state=absent 26 | delegate_to: localhost 27 | with_items: 28 | - "{{ db_hostvars_dir }}/{{ ansible_hostname }}" 29 | - "{{ db_hostvars_file }}" 30 | - "{{ db_inventory_dir }}/{{ ansible_hostname }}.yml" 31 | - "{{ db_inventory_file }}" 32 | 33 | - name: creating yaml list of groups/hosts 34 | template: src=./create_db_inventory_list.yml.j2 dest="{{ db_inventory_dir }}/{{ ansible_hostname }}.yml" 35 | delegate_to: localhost 36 | sudo: false 37 | 38 | - name: merging all host inventory groups into one 39 | assemble: src="{{ db_inventory_dir }}/" dest="{{ db_inventory_file }}" 40 | delegate_to: localhost 41 | run_once: true 42 | sudo: false 43 | 44 | - name: adding list var to inventory file 45 | lineinfile: dest="{{ db_inventory_file }}" regexp="^host_groups" line="host_groups{{ ':' }}" insertbefore=BOF 46 | delegate_to: localhost 47 | run_once: true 48 | sudo: false 49 | 50 | - name: adding yaml formatting to inventory file 51 | lineinfile: dest="{{ db_inventory_file }}" regexp="^---" line="---" insertbefore=BOF 52 | delegate_to: localhost 53 | run_once: true 54 | sudo: false 55 | 56 | - name: chmodding inventory file 57 | file: path="{{ db_inventory_file }}" mode=0775 58 | delegate_to: localhost 59 | run_once: true 60 | -------------------------------------------------------------------------------- /playbooks/db_imports/2_import_db_inventory_to_sqlite.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ### Takes an host_groups Inventory file created by 1_create_host_groups_inventory.yml and creates groups,hosts and associates 3 | ### each of them into Host_Groups DB Table 4 | ### ansible-playbook -i hosts 2_import_db_inventory_to_sqlite.yml 5 | - hosts: localhost 6 | sudo: true 7 | remote_user: remote 8 | vars: 9 | - apache2_root: /var/www/html 10 | - cmdb_sqlite_db_file: '{{ cmdb_sqlite_db_path }}/cmdb.db' 11 | - cmdb_sqlite_db_path: '{{ apache2_root }}/../db' 12 | - sql1: "\"PRAGMA foreign_keys = ON;INSERT OR IGNORE INTO Groups(GroupName,GroupDTAP,GroupCreatedOn,LastUpdateTime) VALUES ('{{ item[1] }}','U',datetime('now'),datetime('now'));\"" 13 | - sql2: "\"PRAGMA foreign_keys = ON;INSERT OR IGNORE INTO Hosts(HostName,HostCreatedOn,LastUpdateTime) VALUES ('{{ item[0].name }}',datetime('now'),datetime('now'));\"" 14 | - sql3: "\"PRAGMA foreign_keys = ON;INSERT OR IGNORE INTO HostGroups(GroupId,GroupName,HostId,HostName) VALUES ( (SELECT GroupId FROM Groups WHERE GroupName='{{ item[1] }}'),(SELECT GroupName FROM Groups WHERE GroupName='{{ item[1] }}'),(SELECT HostId FROM Hosts Where HostName='{{ item[0].name }}'),(SELECT HostName FROM Hosts Where HostName='{{ item[0].name }}') );\"" 15 | vars_files: 16 | - ./db_inventory.yml 17 | tasks: 18 | - name: importing groups into db 19 | shell: "sqlite3 {{ cmdb_sqlite_db_file }} {{ sql1 }}" 20 | delegate_to: cmdb 21 | with_subelements: 22 | - host_groups 23 | - groups 24 | 25 | - name: importing hosts into db 26 | shell: "sqlite3 {{ cmdb_sqlite_db_file }} {{ sql2 }}" 27 | delegate_to: cmdb 28 | with_subelements: 29 | - host_groups 30 | - groups 31 | 32 | - name: adding hosts to groups in db 33 | shell: "sqlite3 {{ cmdb_sqlite_db_file }} {{ sql3 }}" 34 | delegate_to: cmdb 35 | with_subelements: 36 | - host_groups 37 | - groups 38 | -------------------------------------------------------------------------------- /playbooks/db_imports/add_host_details_to_db.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ### gathers info from hosts and creates a sql file to inject into db to update host details 3 | - hosts: all 4 | sudo: true 5 | remote_user: remote 6 | vars: 7 | - cmdb_web_group: www-data 8 | - cmdb_web_user: www-data 9 | - db_hostvars_dir: ./db_hostvars 10 | - db_hostvars_file: ./db_hostvars.sql 11 | - db_inventory_dir: ./db_inventory 12 | - db_inventory_file: ./db_inventory.yml 13 | tasks: 14 | - name: creating hostvars for hosts 15 | template: src=./create_db_hostdetails.sql.j2 dest="{{ db_hostvars_dir }}/{{ ansible_hostname }}" 16 | delegate_to: localhost 17 | sudo: false 18 | 19 | - name: merging all hostvars into one sql 20 | assemble: src="{{ db_hostvars_dir }}/" dest="{{ db_hostvars_file }}" 21 | delegate_to: localhost 22 | run_once: true 23 | sudo: false 24 | 25 | - hosts: cmdb 26 | sudo: true 27 | remote_user: remote 28 | vars: 29 | - apache2_root: /var/www/html 30 | - cmdb_sqlite_db_file: '{{ cmdb_sqlite_db_path }}/cmdb.db' 31 | - cmdb_sqlite_db_path: '{{ apache2_root }}/../db' 32 | - cmdb_web_group: www-data 33 | - cmdb_web_user: www-data 34 | - db_hostvars_dir: ./db_hostvars 35 | - db_hostvars_file: ./db_hostvars.sql 36 | - db_inventory_dir: ./db_inventory 37 | - db_inventory_file: ./db_inventory.yml 38 | tasks: 39 | - name: copying sql file 40 | copy: src="{{ db_hostvars_file }}" dest='{{ cmdb_sqlite_db_path }}' owner='{{ cmdb_web_user }}' group='{{ cmdb_web_group }}' 41 | 42 | - name: adding data to sqlite3 43 | shell: "cat {{ cmdb_sqlite_db_path }}/{{ db_hostvars_file }} | sqlite3 {{ cmdb_sqlite_db_file }}" 44 | -------------------------------------------------------------------------------- /playbooks/db_imports/create_db_hostdetails.sql.j2: -------------------------------------------------------------------------------- 1 | PRAGMA foreign_keys = ON;INSERT OR REPLACE INTO HostDetails(HostId,HostArchitecture,HostBIOSDate,HostBIOSVersion,HostDistribution,HostDistributionRelease,HostDistributionVersion,HostFQDN,HostKernel,HostSystemVendor,HostVirtualizationType,LastUpdateTime,HostInterface,HostInterfaceGateway,HostInterfaceMAC,HostInterfaceNetmask,HostInterfaceAddress,HostProcessor,HostProcessorCores,HostProcessorCount,HostMemFreeMB,HostMemTotalMB,HostOSFamily,HostProductName,HostSwapFree,HostSwapTotal,HostSystemVendor) VALUES( (SELECT HostId FROM Hosts WHERE HostName='{{ inventory_hostname }}'),'{{ ansible_architecture }}','{{ ansible_bios_date }}','{{ ansible_bios_version }}','{{ ansible_distribution }}','{{ ansible_distribution_release }}','{{ ansible_distribution_version }}','{{ ansible_fqdn }}','{{ ansible_kernel }}','{{ ansible_system_vendor }}','{{ ansible_virtualization_type }}',datetime('now'),'{{ ansible_default_ipv4.interface }}','{{ ansible_default_ipv4.gateway }}','{{ ansible_default_ipv4.macaddress }}','{{ ansible_default_ipv4.netmask }}','{{ ansible_default_ipv4.address }}','{{ ansible_processor|join }}','{{ ansible_processor_cores }}','{{ ansible_processor_count}}','{{ ansible_memfree_mb }}','{{ ansible_memtotal_mb }}','{{ ansible_os_family }}','{{ ansible_product_name }}','{{ ansible_swapfree_mb }}','{{ ansible_swaptotal_mb }}','{{ ansible_system_vendor }}'); 2 | -------------------------------------------------------------------------------- /playbooks/db_imports/create_db_inventory_list.yml.j2: -------------------------------------------------------------------------------- 1 | - name: {{ ansible_hostname }} 2 | groups: 3 | {% for group in group_names %} 4 | - {{ group }} 5 | {% endfor %} 6 | -------------------------------------------------------------------------------- /playbooks/db_inventory_list.yml.j2: -------------------------------------------------------------------------------- 1 | - name: {{ ansible_hostname }} 2 | groups: 3 | {% for group in group_names %} 4 | - {{ group }} 5 | {% endfor %} 6 | -------------------------------------------------------------------------------- /playbooks/generate_db_inventory.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | sudo: true 4 | remote_user: remote 5 | vars: 6 | - db_inventory_file: db_inventory 7 | - clear_inventory: true 8 | tasks: 9 | - name: pinging hosts 10 | local_action: ping 11 | register: id_hosts 12 | 13 | - name: delete inventory file 14 | file: path="{{ db_inventory_file }}" state=absent 15 | delegate_to: localhost 16 | run_once: true 17 | when: clear_inventory is defined and clear_inventory 18 | 19 | - name: checking if inventory file exists 20 | stat: path="{{ db_inventory_file }}" 21 | register: db_inventory 22 | delegate_to: localhost 23 | run_once: true 24 | 25 | - name: creating inventory file if not exists 26 | file: path="{{ db_inventory_file }}" state=touch 27 | delegate_to: localhost 28 | run_once: true 29 | when: not db_inventory.stat.exists 30 | 31 | - name: populating db inventory 32 | lineinfile: dest="{{ db_inventory_file }}" line="{{ group_names }}" 33 | delegate_to: localhost 34 | with_items: id_hosts.results 35 | 36 | - name: cleaning up groups 37 | shell: "sed -i -e \"s/[][]//g\" {{ db_inventory_file }}" 38 | delegate_to: localhost 39 | run_once: true 40 | 41 | - name: cleaning up groups 42 | shell: "sed -i -e \"s/'//g\" {{ db_inventory_file }}" 43 | delegate_to: localhost 44 | run_once: true 45 | 46 | - name: cleaning up groups 47 | shell: "tr -s ', ' '\n ' < {{ db_inventory_file }} > {{ db_inventory_file }}.clean" 48 | delegate_to: localhost 49 | run_once: true 50 | 51 | - name: removing duplicate group_names 52 | shell: "sort -u {{ db_inventory_file }}.clean > {{ db_inventory_file }}" 53 | delegate_to: localhost 54 | run_once: true 55 | 56 | - name: reformatting inventory into a usable variable list 57 | shell: "sed -i -e 's/^/ - /' {{ db_inventory_file }}" 58 | delegate_to: localhost 59 | run_once: true 60 | 61 | - name: adding variable name for list 62 | lineinfile: dest="{{ db_inventory_file }}" regexp="^host_groups" line="host_groups{{ ':' }}" insertbefore=BOF 63 | delegate_to: localhost 64 | run_once: true 65 | 66 | - name: adding yaml formatting 67 | lineinfile: dest="{{ db_inventory_file }}" regexp="^---" line="---" insertbefore=BOF 68 | delegate_to: localhost 69 | run_once: true 70 | -------------------------------------------------------------------------------- /playbooks/import_db_inventory_to_sqlite.yml: -------------------------------------------------------------------------------- 1 | - hosts: localhost 2 | sudo: true 3 | remote_user: remote 4 | vars: 5 | - apache2_root: /var/www/html 6 | - cmdb_sqlite_db_file: '{{ cmdb_sqlite_db_path }}/cmdb.db' 7 | - cmdb_sqlite_db_path: '{{ apache2_root }}/db' 8 | - sql1: "\"PRAGMA foreign_keys = ON;INSERT OR IGNORE INTO Groups(GroupName,GroupDTAP,GroupCreatedOn,LastUpdateTime) VALUES ('{{ item[1] }}','U',datetime('now'),datetime('now'));\"" 9 | # - sql2: "\"INSERT OR IGNORE INTO Hosts (HostName,HostCreatedOn,LastUpdateTime,HostGroup) VALUES ('{{ item[0].name }}',datetime('now'),datetime('now'),(SELECT GroupId from Groups WHERE '{{ item[1] }}'=GroupName));\"" 10 | - sql3: "\"PRAGMA foreign_keys = ON;INSERT OR IGNORE INTO Hosts (HostName,HostCreatedOn,LastUpdateTime) VALUES ('{{ item[0].name }}',datetime('now'),datetime('now'));\"" 11 | - sql4: "\"PRAGMA foreign_keys = ON;INSERT OR IGNORE INTO HostGroups (GroupId,GroupName,HostId,HostName) VALUES ( (SELECT GroupId FROM Groups WHERE GroupName='{{ item[1] }}'),(SELECT GroupName FROM Groups WHERE GroupName='{{ item[1] }}'),(SELECT HostId FROM Hosts Where HostName='{{ item[0].name }}'),(SELECT HostName FROM Hosts Where HostName='{{ item[0].name }}') );\"" 12 | 13 | vars_files: 14 | - ./db_inventory.yml 15 | tasks: 16 | - name: importing groups into db 17 | shell: "sqlite3 {{ cmdb_sqlite_db_file }} {{ sql1 }}" 18 | delegate_to: cmdb 19 | with_subelements: 20 | - host_groups 21 | - groups 22 | 23 | - name: importing hosts into db 24 | shell: "sqlite3 {{ cmdb_sqlite_db_file }} {{ sql3 }}" 25 | delegate_to: cmdb 26 | with_subelements: 27 | - host_groups 28 | - groups 29 | 30 | - name: adding hosts to groups in db 31 | shell: "sqlite3 {{ cmdb_sqlite_db_file }} {{ sql4 }}" 32 | delegate_to: cmdb 33 | with_subelements: 34 | - host_groups 35 | - groups 36 | -------------------------------------------------------------------------------- /provision.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt-get update 3 | sudo apt-get install -y git python-pip python-dev sshpass 4 | sudo pip install jinja2 5 | sudo pip install ansible 6 | 7 | sudo ansible-galaxy install -r /vagrant/requirements.yml -f 8 | 9 | ansible-playbook -i "localhost," -c local /vagrant/playbook.yml 10 | -------------------------------------------------------------------------------- /requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - src: https://github.com/mrlesmithjr/ansible-apache2.git 3 | - src: https://github.com/mrlesmithjr/ansible-cmdb.git 4 | - src: https://github.com/mrlesmithjr/ansible-postfix.git 5 | - src: https://github.com/mrlesmithjr/ansible-timezone.git 6 | -------------------------------------------------------------------------------- /screenshots/Ansible_Group_Actions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrlesmithjr/ansible-cmdb/ab2a0d1eb09223d5c6754925623c39d36917803c/screenshots/Ansible_Group_Actions.png -------------------------------------------------------------------------------- /screenshots/Ansible_Host_details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrlesmithjr/ansible-cmdb/ab2a0d1eb09223d5c6754925623c39d36917803c/screenshots/Ansible_Host_details.png -------------------------------------------------------------------------------- /screenshots/Jenkins_Integration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrlesmithjr/ansible-cmdb/ab2a0d1eb09223d5c6754925623c39d36917803c/screenshots/Jenkins_Integration.png -------------------------------------------------------------------------------- /tasks/config_apache2_pages.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: config_apache2_pages | configuring cmdb web pages 3 | template: src='var/www/html/{{ item }}.j2' dest='{{ apache2_root }}/{{ item }}' owner='{{ cmdb_web_user }}' group='{{ cmdb_web_group }}' mode=0644 4 | with_items: 5 | - add_groups.php 6 | - add_group_contact.php 7 | - add_group_host.php 8 | - add_user_links.php 9 | - ansible_actions.php 10 | - ansible_test_jenkins_job.php 11 | - common.php 12 | - common_base.php 13 | - configure_user_jenkins_api.php 14 | - delete_group_contact.php 15 | - delete_group_host.php 16 | - delete_group.php 17 | - edit_group.php 18 | - edit_group_contact.php 19 | - edit_user_jenkins_api.php 20 | - edit_user_info.php 21 | - group_actions.php 22 | - index.php 23 | - login.php 24 | - logout.php 25 | - members.php 26 | - php_details.php 27 | - query_group.php 28 | - query_group_contact_info.php 29 | - query_group_details.php 30 | - query_group_hosts.php 31 | - query_host_details.php 32 | - query_users.php 33 | - register_user.php 34 | - run_group_ansible_playbook.php 35 | - send_group_email.php 36 | - validate_login.php 37 | - view_group_contact_info.php 38 | - view_user_jenkins_api.php 39 | - view_user_links.php 40 | 41 | - name: config_apache2_pages | copying files 42 | copy: src=background.jpg dest='{{ apache2_root }}' owner='{{ cmdb_web_user }}' group='{{ cmdb_web_group }}' 43 | 44 | - name: config_apache2_pages | cleaning up old pages 45 | file: path='{{ apache2_root }}/{{ item }}' state=absent 46 | with_items: 47 | - add_group_contact.html 48 | - add_group_contact_info.html 49 | - add_group_contact_info.php 50 | - add_group_host.html 51 | - add_groups.html 52 | - add_groups_db.php 53 | - add_user_links.html 54 | - ansible_actions.html 55 | - calendar.php 56 | - create_user.html 57 | - create_user.php 58 | - db_actions.php 59 | - db_query.php 60 | - db_tables.php 61 | - delete_group.html 62 | - delete_group_host.html 63 | - delete_group_hosts.html 64 | - delete_group_hosts.php 65 | - delete_groups.html 66 | - delete_groups.php 67 | - edit_group.html 68 | - edit_group_contact.html 69 | - edit_group_contact_info.html 70 | - edit_group_contact_info.php 71 | - email.html 72 | - email_groups.html 73 | - groups.html 74 | - groups.php 75 | - host_actions.php 76 | - index.html 77 | - query_groups_db.php 78 | - register_user.html 79 | - send_group_email.html 80 | - test.php 81 | - user_actions.php 82 | - version.php 83 | - view_jenkins_api.php 84 | -------------------------------------------------------------------------------- /tasks/config_php5_apache2.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: config_php5_apache2 | configuring php5 for apache2 3 | template: src=etc/php5/apache2/php.ini.j2 dest=/etc/php5/apache2/php.ini owner=root group=root mode=0644 4 | notify: restart apache2 5 | 6 | - name: config_php5_apache2 | enabling php5 module 7 | apache2_module: name=php5 state=present 8 | notify: restart apache2 9 | 10 | - name: config_php5_apache2 | enabling php5-mcrypt 11 | shell: php5enmod mcrypt creates=/etc/php5/cli/conf.d/20-mcrypt.ini 12 | notify: restart apache2 13 | -------------------------------------------------------------------------------- /tasks/config_sqlite.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: config_sqlite | creating db folder cmdb 3 | file: path='{{ cmdb_sqlite_db_path }}' owner='{{ cmdb_web_user }}' group='{{ cmdb_web_group }}' mode=0774 state=directory 4 | 5 | - name: config_sqlite | checking for existing db for cmdb 6 | stat: path='{{ cmdb_sqlite_db_file }}' 7 | register: db_file 8 | 9 | - name: config_sqlite | creating db for cmdb 10 | file: path='{{ cmdb_sqlite_db_file }}' owner='{{ cmdb_web_user }}' group='{{ cmdb_web_group }}' mode=0774 state=touch 11 | when: not db_file.stat.exists 12 | 13 | - name: config_sqlite | copying cmdb schema 14 | copy: src=cmdb_schema.sql dest='{{ cmdb_sqlite_db_path }}' owner='{{ cmdb_web_user }}' group='{{ cmdb_web_group }}' 15 | 16 | #- name: config_sqlite | checking if cmdb schema already imported 17 | # stat: path='{{ cmdb_sqlite_db_path }}/.schema_imported' 18 | # register: cmdb_schema 19 | 20 | - name: config_sqlite | importing cmdb schema 21 | shell: "cat {{ cmdb_sqlite_db_path }}/cmdb_schema.sql | sqlite3 {{ cmdb_sqlite_db_file }}" 22 | # register: cmdb_schema_imported 23 | # when: not cmdb_schema.stat.exists 24 | 25 | #- name: config_sqlite | marking cmdb schema as imported 26 | # file: path='{{ cmdb_sqlite_db_path }}/.schema_imported' state=touch 27 | # when: cmdb_schema_imported.changed 28 | -------------------------------------------------------------------------------- /tasks/debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: debian | installing pre-reqs 3 | apt: name={{ item }} state=present 4 | notify: restart apache2 5 | with_items: 6 | - apache2 7 | - curl 8 | - libapache2-mod-php5 9 | - libcurl3 10 | - libsqlite3-dev 11 | - php5-curl 12 | - php5-mcrypt 13 | - php5-sqlite 14 | - sqlite3 15 | 16 | - name: debian | adding ansible ppa 17 | apt_repository: repo='ppa:ansible/ansible' 18 | when: install_ansible is defined and install_ansible 19 | 20 | - name: debian | installing ansible 21 | apt: name=ansible state=latest 22 | when: install_ansible is defined and install_ansible 23 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for ansible-cmdb 3 | - include: debian.yml 4 | 5 | - include: config_php5_apache2.yml 6 | tags: [config_php5_apache2] 7 | 8 | - include: config_sqlite.yml 9 | tags: [config_sqlite] 10 | 11 | - include: config_apache2_pages.yml 12 | tags: [config_apache2_pages] 13 | -------------------------------------------------------------------------------- /templates/var/www/html/add_group_contact.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | "; 28 | echo ""; 29 | session_start(); 30 | $gid = $_SESSION['sessiongid']; 31 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 32 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 33 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 34 | $results = $db->query($sql); 35 | while ($row = $results->fetchArray()) { 36 | echo "
";
37 |           echo "GroupId: ";
38 |           echo "" . $row['GroupId']. "";
39 |           echo "
"; 40 | echo "
";
41 |           echo "GroupName: ";
42 |           echo "" . $row['GroupName']. "
"; 43 | echo "
"; 44 | echo "
";
45 |           echo "GroupDescription: ";
46 |           echo "" . $row['GroupDescription']. "
"; 47 | echo "
"; 48 | echo "
";
49 |           echo "GroupDTAP: ";
50 |           echo "" . $row['GroupDTAP']. "
"; 51 | echo "
"; 52 | echo "
";
53 |           echo "GroupCreatedOn: ";
54 |           echo "" . $row['GroupCreatedOn']. "
"; 55 | echo "
"; 56 | echo "
";
57 |           echo "LastUpdateTime: ";
58 |           echo "" . $row['LastUpdateTime']. "
"; 59 | echo "


"; 60 | } 61 | echo ""; 62 | echo ""; 63 | ?> 64 |

Check existing contacts in group:

65 |
66 | 80 | 81 | 82 |


83 |

(** - Denotes required field)

84 |
85 | Contact name: (**)

86 | Contact email: (**)

87 | Contact phone: (**)

88 | 89 | 90 |
91 | 92 | 93 | -------------------------------------------------------------------------------- /templates/var/www/html/add_group_contact.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 10 | echo ""; 11 | session_start(); 12 | $gid = $_SESSION['sessiongid']; 13 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 14 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 15 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 16 | $results = $db->query($sql); 17 | while ($row = $results->fetchArray()) { 18 | echo "



"; 19 | echo "
";
 20 |       echo "GroupId: ";
 21 |       echo "" . $row['GroupId']. "";
 22 |       echo "
"; 23 | echo "
";
 24 |       echo "GroupName: ";
 25 |       echo "" . $row['GroupName']. "
"; 26 | echo "
"; 27 | echo "
";
 28 |       echo "GroupDescription: ";
 29 |       echo "" . $row['GroupDescription']. "
"; 30 | echo "
"; 31 | echo "
";
 32 |       echo "GroupDTAP: ";
 33 |       echo "" . $row['GroupDTAP']. "
"; 34 | echo "
"; 35 | echo "
";
 36 |       echo "GroupCreatedOn: ";
 37 |       echo "" . $row['GroupCreatedOn']. "
"; 38 | echo "
"; 39 | echo "
";
 40 |       echo "LastUpdateTime: ";
 41 |       echo "" . $row['LastUpdateTime']. "
"; 42 | echo "


"; 43 | } 44 | echo ""; 45 | echo ""; 46 | ?> 47 | exec( 'PRAGMA foreign_keys = ON;' ); 56 | $sql = "INSERT INTO GroupContact (ContactName,ContactEmail,ContactPhone,ContactCreatedOn,GroupId) VALUES ('$cn','$ce','$cp',datetime('now'),'$gid')"; 57 | if (empty($_POST["ContactName"])) { 58 | echo "Contact name has not been entered"; 59 | } 60 | if (empty($_POST["ContactEmail"])) { 61 | echo "Contact e-mail has not been entered"; 62 | } 63 | if (empty($_POST["ContactPhone"])) { 64 | echo "Contact phone number has not been entered"; 65 | } 66 | if (!empty($_POST["ContactName"]) && !empty($_POST["ContactEmail"]) && !empty($_POST["ContactPhone"])) { 67 | $db->exec($sql); 68 | echo "Group contact has been added."; 69 | } 70 | } 71 | ?> 72 | 73 | 74 | 75 |

Check existing contacts in group:

76 |
77 | 91 | 92 | 93 |


94 |

(** - Denotes required field)

95 |
96 | Contact name: (**)

97 | Contact email: (**)

98 | Contact phone: (**)

99 | 100 | 101 |
102 | 103 | 104 | -------------------------------------------------------------------------------- /templates/var/www/html/add_group_host.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | "; 28 | echo ""; 29 | session_start(); 30 | $gid = $_SESSION['sessiongid']; 31 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 32 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 33 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 34 | $results = $db->query($sql); 35 | while ($row = $results->fetchArray()) { 36 | echo "
";
37 |           echo "GroupId: ";
38 |           echo "" . $row['GroupId']. "";
39 |           echo "
"; 40 | echo "
";
41 |           echo "GroupName: ";
42 |           echo "" . $row['GroupName']. "
"; 43 | echo "
"; 44 | echo "
";
45 |           echo "GroupDescription: ";
46 |           echo "" . $row['GroupDescription']. "
"; 47 | echo "
"; 48 | echo "
";
49 |           echo "GroupDTAP: ";
50 |           echo "" . $row['GroupDTAP']. "
"; 51 | echo "
"; 52 | echo "
";
53 |           echo "GroupCreatedOn: ";
54 |           echo "" . $row['GroupCreatedOn']. "
"; 55 | echo "
"; 56 | echo "
";
57 |           echo "LastUpdateTime: ";
58 |           echo "" . $row['LastUpdateTime']. "
"; 59 | echo "


"; 60 | } 61 | echo ""; 62 | echo ""; 63 | ?> 64 |

Check existing hosts in group:

65 |
66 |

78 |

(** - Denotes required field)

79 | 80 | Host Name: (**)

81 | Host Description:

82 | 83 | 84 |
85 | 86 | 87 | -------------------------------------------------------------------------------- /templates/var/www/html/add_group_host.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 10 | echo ""; 11 | session_start(); 12 | $gid = $_SESSION['sessiongid']; 13 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 14 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 15 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 16 | $results = $db->query($sql); 17 | while ($row = $results->fetchArray()) { 18 | echo "



"; 19 | echo "
";
 20 |       echo "GroupId: ";
 21 |       echo "" . $row['GroupId']. "";
 22 |       echo "
"; 23 | echo "
";
 24 |       echo "GroupName: ";
 25 |       echo "" . $row['GroupName']. "
"; 26 | echo "
"; 27 | echo "
";
 28 |       echo "GroupDescription: ";
 29 |       echo "" . $row['GroupDescription']. "
"; 30 | echo "
"; 31 | echo "
";
 32 |       echo "GroupDTAP: ";
 33 |       echo "" . $row['GroupDTAP']. "
"; 34 | echo "
"; 35 | echo "
";
 36 |       echo "GroupCreatedOn: ";
 37 |       echo "" . $row['GroupCreatedOn']. "
"; 38 | echo "
"; 39 | echo "
";
 40 |       echo "LastUpdateTime: ";
 41 |       echo "" . $row['LastUpdateTime']. "
"; 42 | echo "


"; 43 | } 44 | echo ""; 45 | echo ""; 46 | ?> 47 | exec( 'PRAGMA foreign_keys = ON;' ); 55 | $sql1 = "INSERT INTO Hosts 56 | (HostName,HostDescription,LastUpdateTime,HostCreatedOn) 57 | VALUES ('$hn','$hd',datetime('now'),datetime('now'))"; 58 | $sql2 = "INSERT INTO HostGroups 59 | (GroupId,GroupName,HostId,HostName) 60 | VALUES ( '$gid',(SELECT GroupName FROM Groups WHERE GroupId='$gid'),(SELECT HostId FROM Hosts Where HostName='$hn'),'$hn')"; 61 | if (empty($_POST["HostName"])) { 62 | echo "Host Name has not been entered"; 63 | } 64 | if (!empty($_POST["HostName"])) { 65 | $db->exec($sql1); 66 | $db->exec($sql2); 67 | echo "Host $hn has been added."; 68 | } 69 | } 70 | ?> 71 | 72 | 73 | 74 |

Hosts assigned to group:

75 |
76 | 90 | 91 |
92 |

(** - Denotes required field)

93 |
94 | Host Name: (**)

95 | Host Description:

96 | 97 | 98 |
99 | 100 | 101 | -------------------------------------------------------------------------------- /templates/var/www/html/add_groups.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 |

Check existing groups:

27 |
28 | 40 | 41 |


42 |

Create New CMDB Group

43 |

(** - Denotes required field)

44 |
45 | Group name: (**)

46 | Group description:

47 | Group DTAP: (**)

53 | 54 | 55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /templates/var/www/html/add_groups.php.j2: -------------------------------------------------------------------------------- 1 | 8 | exec( 'PRAGMA foreign_keys = ON;' ); 12 | $sql = "INSERT INTO Groups 13 | (GroupName,GroupDescription,GroupDTAP,GroupCreatedOn,LastUpdateTime) 14 | VALUES('$gn','$gd','$gdtap',datetime('now'),datetime('now'))"; 15 | $gn = $_POST["GroupName"]; 16 | $gd = $_POST["GroupDescription"]; 17 | $gdtap = $_POST["GroupDTAP"]; 18 | if (empty($_POST["GroupName"])) { 19 | echo "Group Name has not been entered"; 20 | } 21 | if (!empty($_POST["GroupName"])) { 22 | $db->exec($sql); 23 | echo "Group $gn has been added."; 24 | } 25 | } 26 | ?> 27 | 28 | 29 | 30 |



31 |

Check existing groups:

32 |
33 | 45 | 46 |


47 |

Create New CMDB Group

48 |

(** - Denotes required field)

49 |
50 | Group name: (**)

51 | Group description:

52 | Group DTAP: (**)

58 | 59 | 60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /templates/var/www/html/add_user_links.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 |



11 |

Create New External Link

12 |

(** - Required)

13 |
14 | Link name: (**)

15 | Link URL: (**)

16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /templates/var/www/html/ansible_actions.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | {{ cmdb_web_title|upper }}



27 |
28 |

Ansible Actions:


32 | 33 | 35 |



36 | 37 | 38 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /templates/var/www/html/ansible_actions.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 16 | 17 | 18 | 19 | 20 |

Ansible Actions:


24 | 25 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /templates/var/www/html/ansible_test_jenkins_job.php.j2: -------------------------------------------------------------------------------- 1 | 8 |


"; 15 | echo "Job executed on Jenkins server."; 16 | echo "
"; 17 | echo "Check Jenkins for status."; 18 | ?> 19 | -------------------------------------------------------------------------------- /templates/var/www/html/calendar.php.j2: -------------------------------------------------------------------------------- 1 | setIcon("calendar/images/iconCalendar.gif"); 4 | $myCalendar->setDate(date('d'), date('m'), date('Y')); 5 | $myCalendar->setPath("calendar/"); 6 | $myCalendar->setYearInterval(1890, 2080); 7 | 8 | $myCalendar->dateAllow('1890-01-01', '2045-05-01', false); 9 | 10 | $myCalendar->setSpecificDate(array("2039-01-10", "2039-01-13", "2039-01-23"), 0, 'month'); 11 | 12 | $myCalendar->startMonday(true); 13 | $myCalendar->showWeeks(true); 14 | 15 | //Tooltips 16 | $myCalendar->setToolTips(array("2013-07-02", "2013-07-15", "2013-07-25"), 'ŞŢĂÎÂ şţăîâ אי אפשר test!', ''); 17 | $myCalendar->setToolTips(array("2013-06-06", "2013-06-01", "2013-06-05"), 'אי אפשר לבחור תאריך זה', 'month'); 18 | $myCalendar->setToolTips(array("1969-07-06", "2040-07-01", "2013-06-05") 19 | , 'Δεν επιτρέπετε η επιλογή αυτής της ημέρας', 'month'); 20 | $myCalendar->setToolTips(array("1969-07-06", "2040-07-01", "2013-06-05") 21 | , 'الإصدار الخاص بي ليس لديها الدعم للعام 2038 وفيما بعد!', 'month'); 22 | $myCalendar->setToolTips(array("1969-07-06", "2040-07-01", "2013-06-05"), 'の間の日付を選択してください', 'month'); 23 | $myCalendar->setToolTips(array("1969-07-06", "2040-07-01", "2013-06-05"), '올바르지 않은 값입니다', 'month'); 24 | $myCalendar->setToolTips(array("2013-06-06", "2013-06-11", "2013-06-15"), 'और बाद के वर्षों का समर्थन नहीं है!', 'month'); 25 | $myCalendar->setToolTips(array("2013-07-06", "2013-01-01", "2013-12-25"), 'วันนี้ไม่ได้รับอนุญาตให้มีการเลือก', 'year'); 26 | $myCalendar->setToolTips(array("2013-07-06", "2013-07-15", "2013-07-25"), '请选择日期%s之前一个', ''); 27 | 28 | $myCalendar->setTimezone("Australia/Melbourne"); 29 | $myCalendar->writeScript(); 30 | ?> 31 | -------------------------------------------------------------------------------- /templates/var/www/html/common.php.j2: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {{ cmdb_web_title }} 19 | 161 | 162 | 163 | 209 |
210 |

Register | Login | Logout

211 |
212 | 213 | 214 | -------------------------------------------------------------------------------- /templates/var/www/html/common_base.php.j2: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {{ cmdb_web_title }} 19 | 58 | 59 | 60 |
61 |

Register | Login | Logout

62 |
63 | 64 | 65 | -------------------------------------------------------------------------------- /templates/var/www/html/configure_user_jenkins_api.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 |



11 |

Setup Jenkins API Token

12 |

(** - Required)

13 | 14 | Jenkins URL: (**)

15 | Jenkins API Token UserId: (**)

16 | Jenkins API Token: (**)

17 | 18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /templates/var/www/html/create_user.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 |

(** - Denotes required field)

27 |
28 | Username: (**)

29 | Password: (**)

30 | First name: (**)

31 | Last name: (**)

32 | Email: (**)

33 | Phone:

34 | 35 | 36 |
37 |



38 | 39 | 40 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /templates/var/www/html/create_user.php.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | exec( 'PRAGMA foreign_keys = ON;' ); 36 | $sql = "INSERT INTO Users (UserName,Email,FirstName,LastName,Password,Phone) VALUES ('$username','$email','$firstname','$lastname','$passwordhash','$phone')"; 37 | if (empty($username)) { 38 | echo "
";
39 |       echo "Username was not entered..";
40 |       echo "
"; 41 | } 42 | if (empty($firstname)) { 43 | echo "
";
44 |       echo "First name was not entered..";
45 |       echo "
"; 46 | } 47 | if (empty($lastname)) { 48 | echo "
";
49 |       echo "Last name was not entered..";
50 |       echo "
"; 51 | } 52 | if (empty($email)) { 53 | echo "
";
54 |       echo "Email was not entered..";
55 |       echo "
"; 56 | } 57 | if (empty($password)) { 58 | echo "
";
59 |       echo "Password was not entered..";
60 |       echo "
"; 61 | } 62 | if (!empty($username) && !empty($firstname) && !empty($lastname) && !empty($email) && !empty($password)) { 63 | $db->exec($sql); 64 | echo "User $username has been created."; 65 | } 66 | ?> 67 |



68 | 69 | 70 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /templates/var/www/html/delete_group.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 |
27 | 39 | 40 | 41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /templates/var/www/html/delete_group.php.j2: -------------------------------------------------------------------------------- 1 | 8 | exec( 'PRAGMA foreign_keys = ON;' ); 15 | $sql = "DELETE FROM Groups 16 | WHERE GroupId=$gid"; 17 | $db->exec($sql); 18 | echo "Group $gn has been deleted."; 19 | } 20 | if(isset($_POST['Delete_Group']) && $_POST['Delete_Group'] == 'No') { 21 | $url = 'query_group.php'; 22 | session_start(); 23 | $gid = $_SESSION['sessiongid']; 24 | $_SESSION['sessiongid'] = $gid; 25 | } 26 | if(isset($url)) { 27 | header("Location: $url"); 28 | exit; 29 | } 30 | ?> 31 | 32 | 33 | 34 |
35 |

(** - Are you sure you want to delete $gn ??)

36 | 41 | 42 | 43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /templates/var/www/html/delete_group_contact.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | exec( 'PRAGMA foreign_keys = ON;' ); 17 | $sql1 = "SELECT ContactName FROM GroupContact 18 | WHERE ContactId=$cid"; 19 | $results = $db->query($sql1); 20 | while ($row = $results->fetchArray()) { 21 | $cn = $row['ContactName']; 22 | } 23 | $sql2 = "DELETE FROM GroupContact 24 | WHERE ContactId=$cid"; 25 | $db->exec($sql2); 26 | echo "Group contact $cn has been deleted."; 27 | ?> 28 |

29 |

30 | 31 | 32 | -------------------------------------------------------------------------------- /templates/var/www/html/delete_group_host.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | "; 28 | echo ""; 29 | session_start(); 30 | $gid = $_SESSION['sessiongid']; 31 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 32 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 33 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 34 | $results = $db->query($sql); 35 | while ($row = $results->fetchArray()) { 36 | echo "
";
37 | 						echo "GroupId: ";
38 | 						echo "" . $row['GroupId']. "";
39 | 						echo "
"; 40 | echo "
";
41 | 						echo "GroupName: ";
42 | 						echo "" . $row['GroupName']. "
"; 43 | echo "
"; 44 | echo "
";
45 | 						echo "GroupDescription: ";
46 | 						echo "" . $row['GroupDescription']. "
"; 47 | echo "
"; 48 | echo "
";
49 | 						echo "GroupDTAP: ";
50 | 						echo "" . $row['GroupDTAP']. "
"; 51 | echo "
"; 52 | echo "
";
53 | 						echo "GroupCreatedOn: ";
54 | 						echo "" . $row['GroupCreatedOn']. "
"; 55 | echo "
"; 56 | echo "
";
57 | 						echo "LastUpdateTime: ";
58 | 						echo "" . $row['LastUpdateTime']. "
"; 59 | echo "


"; 60 | } 61 | echo ""; 62 | echo ""; 63 | ?> 64 |

Select host to delete:

65 |
66 | 78 | 79 | 80 |
81 | 82 | 83 | -------------------------------------------------------------------------------- /templates/var/www/html/delete_group_host.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 10 | echo ""; 11 | session_start(); 12 | $gid = $_SESSION['sessiongid']; 13 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 14 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 15 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 16 | $results = $db->query($sql); 17 | while ($row = $results->fetchArray()) { 18 | echo "



"; 19 | echo "
";
20 |       echo "GroupId: ";
21 |       echo "" . $row['GroupId']. "";
22 |       echo "
"; 23 | echo "
";
24 |       echo "GroupName: ";
25 |       echo "" . $row['GroupName']. "
"; 26 | echo "
"; 27 | echo "
";
28 |       echo "GroupDescription: ";
29 |       echo "" . $row['GroupDescription']. "
"; 30 | echo "
"; 31 | echo "
";
32 |       echo "GroupDTAP: ";
33 |       echo "" . $row['GroupDTAP']. "
"; 34 | echo "
"; 35 | echo "
";
36 |       echo "GroupCreatedOn: ";
37 |       echo "" . $row['GroupCreatedOn']. "
"; 38 | echo "
"; 39 | echo "
";
40 |       echo "LastUpdateTime: ";
41 |       echo "" . $row['LastUpdateTime']. "
"; 42 | echo "


"; 43 | } 44 | echo ""; 45 | echo ""; 46 | ?> 47 | exec( 'PRAGMA foreign_keys = ON;' ); 53 | $sql = "DELETE FROM Hosts 54 | WHERE HostId=$hid"; 55 | $db->exec($sql); 56 | echo "Host has been deleted."; 57 | } 58 | ?> 59 | 60 | 61 | 62 |

Select host to delete:

63 |
64 | 78 | 79 | 80 |
81 | 82 | 83 | -------------------------------------------------------------------------------- /templates/var/www/html/edit_group.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | "; 30 | echo ""; 31 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 32 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 33 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 34 | $results = $db->query($sql); 35 | while ($row = $results->fetchArray()) { 36 | echo "
";
37 | 			      echo "GroupId: ";
38 | 			      echo "" . $row['GroupId']. "";
39 | 			      echo "
"; 40 | echo "
";
41 | 			      echo "GroupName: ";
42 | 			      echo "" . $row['GroupName']. "
"; 43 | echo "
"; 44 | echo "
";
45 | 			      echo "GroupDescription: ";
46 | 			      echo "" . $row['GroupDescription']. "
"; 47 | echo "
"; 48 | echo "
";
49 | 			      echo "GroupDTAP: ";
50 | 			      echo "" . $row['GroupDTAP']. "
"; 51 | echo "
"; 52 | echo "
";
53 | 			      echo "LastUpdateTime: ";
54 | 			      echo "" . $row['LastUpdateTime']. "
"; 55 | echo "
"; 56 | } 57 | echo ""; 58 | echo "

"; 59 | ?> 60 |

(** - Denotes required field)

61 |
62 | Group name: (**)

63 | Group description:

64 | Group DTAP: (**)

70 | 71 | 72 |
73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /templates/var/www/html/edit_group.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 10 | echo ""; 11 | session_start(); 12 | $gid = $_SESSION['sessiongid']; 13 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 14 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 15 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 16 | $results = $db->query($sql); 17 | while ($row = $results->fetchArray()) { 18 | echo "



"; 19 | echo "
";
20 |       echo "GroupId: ";
21 |       echo "" . $row['GroupId']. "";
22 |       echo "
"; 23 | echo "
";
24 |       echo "GroupName: ";
25 |       echo "" . $row['GroupName']. "
"; 26 | echo "
"; 27 | echo "
";
28 |       echo "GroupDescription: ";
29 |       echo "" . $row['GroupDescription']. "
"; 30 | echo "
"; 31 | echo "
";
32 |       echo "GroupDTAP: ";
33 |       echo "" . $row['GroupDTAP']. "
"; 34 | echo "
"; 35 | echo "
";
36 |       echo "GroupCreatedOn: ";
37 |       echo "" . $row['GroupCreatedOn']. "
"; 38 | echo "
"; 39 | echo "
";
40 |       echo "LastUpdateTime: ";
41 |       echo "" . $row['LastUpdateTime']. "
"; 42 | echo "


"; 43 | } 44 | echo ""; 45 | echo ""; 46 | ?> 47 | exec( 'PRAGMA foreign_keys = ON;' ); 56 | $sql = "UPDATE Groups 57 | SET GroupName='$groupname', GroupDescription='$gd', GroupDTAP='$gdtap', LastUpdateTime=datetime('now') 58 | WHERE GroupId='$gid'"; 59 | $db->exec($sql); 60 | echo "Group has been updated to $groupname."; 61 | } 62 | ?> 63 | 64 | 65 | 66 |

(** - Denotes required field)

67 |
68 | Group name: (**)

69 | Group description:

70 | Group DTAP: (**)

76 | 77 | 78 |
79 | 80 | 81 | -------------------------------------------------------------------------------- /templates/var/www/html/edit_group_contact.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | "; 28 | echo ""; 29 | session_start(); 30 | $cid = $_SESSION['sessioncid']; 31 | $gid = $_SESSION['sessiongid']; 32 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 33 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 34 | $sql = "SELECT * FROM GroupContact WHERE ContactId=$cid"; 35 | $results = $db->query($sql); 36 | while ($row = $results->fetchArray()) { 37 | echo "
";
38 | 						echo "ContactId: ";
39 | 						echo "" . $row['ContactId']. "";
40 | 						echo "
"; 41 | echo "
";
42 | 						echo "ContactName: ";
43 | 						echo "" . $row['ContactName']. "
"; 44 | echo "
"; 45 | echo "
";
46 | 						echo "ContactEmail: ";
47 | 						echo "" . $row['ContactEmail']. "
"; 48 | echo "
"; 49 | echo "
";
50 | 						echo "ContactPhone: ";
51 | 						echo "" . $row['ContactPhone']. "
"; 52 | echo "
"; 53 | } 54 | echo ""; 55 | echo "

"; 56 | ?> 57 | 62 |

(** - Denotes required field)

63 |
64 | Contact name: (**)

65 | Contact email: (**)

66 | Contact phone: (**)

67 | 68 | 69 |
70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /templates/var/www/html/edit_group_contact.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 10 | echo ""; 11 | session_start(); 12 | $cid = $_SESSION['sessioncid']; 13 | $gid = $_SESSION['sessiongid']; 14 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 15 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 16 | $sql = "SELECT * FROM GroupContact 17 | WHERE ContactId=$cid"; 18 | $results = $db->query($sql); 19 | while ($row = $results->fetchArray()) { 20 | echo "
";
21 |       echo "ContactId: ";
22 |       echo "" . $row['ContactId']. "";
23 |       echo "
"; 24 | echo "
";
25 |       echo "ContactName: ";
26 |       echo "" . $row['ContactName']. "
"; 27 | echo "
"; 28 | echo "
";
29 |       echo "ContactEmail: ";
30 |       echo "" . $row['ContactEmail']. "
"; 31 | echo "
"; 32 | echo "
";
33 |       echo "ContactPhone: ";
34 |       echo "" . $row['ContactPhone']. "
"; 35 | echo "
"; 36 | } 37 | echo ""; 38 | echo "

"; 39 | ?> 40 | exec( 'PRAGMA foreign_keys = ON;' ); 49 | $sql = "UPDATE GroupContact 50 | SET ContactName='$cn', ContactEmail='$ce', ContactPhone='$cp', LastUpdateTime=datetime('now') 51 | WHERE GroupId='$gid'"; 52 | $db->exec($sql); 53 | echo "Group contact has been updated."; 54 | } 55 | ?> 56 | 57 | 58 | 59 |

(** - Denotes required field)

60 |
61 | Contact name: (**)

62 | Contact email: (**)

63 | Contact phone: (**)

64 | 65 | 66 |
67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /templates/var/www/html/edit_user_info.php.j2: -------------------------------------------------------------------------------- 1 | 8 | exec( 'PRAGMA foreign_keys = ON;' ); 11 | $sql = "SELECT * 12 | FROM Users 13 | WHERE UserName='$username' 14 | LIMIT 1"; 15 | $results = $db->query($sql) or die('Query failed'); 16 | // Credentials match so we create session variables 17 | while ($row = $results->fetchArray()) { 18 | echo "



"; 19 | echo "

My Info

"; 20 | echo "
";
21 |     echo "Username: ";
22 |     echo "" . $row['UserName']. "
"; 23 | echo "
"; 24 | echo "
";
25 |     echo "First name: ";
26 |     echo "" . $row['FirstName']. "
"; 27 | echo "
"; 28 | echo "
";
29 |     echo "Last name: ";
30 |     echo "" . $row['LastName']. "
"; 31 | echo "
"; 32 | echo "
";
33 |     echo "E-Mail: ";
34 |     echo "" . $row['Email']. "
"; 35 | echo "
"; 36 | echo "
";
37 |     echo "Phone: ";
38 |     echo "" . $row['Phone']. "
"; 39 | echo "
"; 40 | echo "
";
41 |     echo "Site role: ";
42 |     echo "" . $row['Role']. "
"; 43 | echo "
"; 44 | } 45 | ?> 46 | 47 | 48 | 49 |

Update Field(s) To Change

50 |
51 | First name:

52 | Last name:

53 | Email:

54 | Phone:

55 | 56 | 57 |
58 | 59 | 60 | -------------------------------------------------------------------------------- /templates/var/www/html/edit_user_jenkins_api.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 12 | 13 | 14 | 15 |



16 |

Change Jenkins API Token

17 |

(** - Required)

18 |
19 | Jenkins URL: (**)

20 | Jenkins API Token (User ID): (**)

21 | Jenkins API Token: (**)

22 | 23 | 24 |
25 |



26 |

Delete Jenkins API Token

27 |
28 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /templates/var/www/html/group_actions.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /templates/var/www/html/index.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | {{ cmdb_web_title|upper }}



27 |
28 |

Links:

29 | 37 | 38 | 39 |
40 |

41 |
42 |

Group Actions:

43 | 49 | 50 | 51 |
52 |

53 |
54 |

Ansible Actions:

55 | 59 | 60 | 61 |
62 |
Create User
63 | 64 | 65 | -------------------------------------------------------------------------------- /templates/var/www/html/index.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /templates/var/www/html/login.php.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 80 | 81 | 82 |
{{ cmdb_web_title|upper }}
83 |
84 | Username:

85 | Password:

86 | 87 | 88 |
89 |
90 |

Register | Login

91 |
92 | 93 | 94 | -------------------------------------------------------------------------------- /templates/var/www/html/logout.php.j2: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /templates/var/www/html/members.php.j2: -------------------------------------------------------------------------------- 1 | 8 |


"; 12 | echo "

My Info

"; 13 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}') or die('Create db failed'); 14 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 15 | $sql = "SELECT * 16 | FROM Users 17 | WHERE UserName='$username' 18 | LIMIT 1"; 19 | $results = $db->query($sql) or die('Query failed'); 20 | // Credentials match so we create session variables 21 | while ($row = $results->fetchArray()) { 22 | echo "
";
 23 |       echo "Username: ";
 24 |       echo "" . $row['UserName']. "
"; 25 | echo "
"; 26 | echo "
";
 27 |       echo "First name: ";
 28 |       echo "" . $row['FirstName']. "
"; 29 | echo "
"; 30 | echo "
";
 31 |       echo "Last name: ";
 32 |       echo "" . $row['LastName']. "
"; 33 | echo "
"; 34 | echo "
";
 35 |       echo "E-Mail: ";
 36 |       echo "" . $row['Email']. "
"; 37 | echo "
"; 38 | echo "
";
 39 |       echo "Phone: ";
 40 |       echo "" . $row['Phone']. "
"; 41 | echo "
"; 42 | echo "
";
 43 |       echo "Site role: ";
 44 |       echo "" . $row['Role']. "
"; 45 | echo "
"; 46 | } 47 | } 48 | if($action == 'addlinks') { 49 | include 'add_user_links.php'; 50 | } 51 | if($action == 'addlink') { 52 | if(isset($_POST['Submit'])) { 53 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}') or die('Create db failed'); 54 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 55 | $ln = $_POST["LinkName"]; 56 | $lu = $_POST["LinkUrl"]; 57 | $sql = "INSERT INTO UsersLinks 58 | (Name,Url,UserId) 59 | VALUES('$ln','$lu','$uid')"; 60 | if (empty($ln)) { 61 | echo "Link Name has not been entered"; 62 | } 63 | if (empty($lu)) { 64 | echo "Link Url has not been entered"; 65 | } 66 | if (!empty($ln) && !empty($lu)) { 67 | $db->exec($sql); 68 | echo "Link $ln $lu has been added."; 69 | } 70 | } 71 | } 72 | if($action == 'configurejenkinsapi') { 73 | include 'configure_user_jenkins_api.php'; 74 | } 75 | if($action == 'configurejenkinsapi') { 76 | if(isset($_POST['Submit'])) { 77 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}') or die('Create db failed'); 78 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 79 | $jurl = $_POST["JenkinsURL"]; 80 | $juser = $_POST["JenkinsAPITokenUserId"]; 81 | $juapitoken = $_POST["JenkinsUserAPIToken"]; 82 | $sql = "INSERT INTO UsersExtAPILinks 83 | (JenkinsURL,JenkinsAPITokenUserId,JenkinsUserAPIToken,UserId) 84 | VALUES('$jurl','$juser','$juapitoken','$uid')"; 85 | if (empty($jurl)) { 86 | echo "JenkinsURL has not been entered"; 87 | } 88 | if (empty($juser)) { 89 | echo "JenkinsUser has not been entered"; 90 | } 91 | if (empty($juapitoken)) { 92 | echo "JenkinsUserAPIToken has not been entered"; 93 | } 94 | if (!empty($jurl) && !empty($juser) && !empty($juapitoken)) { 95 | $db->exec($sql); 96 | echo "Jenkins API Configuration has been added."; 97 | } 98 | } 99 | } 100 | if($action == 'deletejenkinsapi') { 101 | if(isset($_POST['Submit'])) { 102 | session_start(); 103 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}') or die('Create db failed'); 104 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 105 | $juapitoken = $_SESSION['sessionjuapitoken']; 106 | $db->exec("DELETE FROM UsersExtAPILinks WHERE UserId='$uid' AND JenkinsUserAPIToken='$juapitoken'"); 107 | } 108 | } 109 | if($action == 'editjenkinsapi') { 110 | if(isset($_POST['Submit'])) { 111 | session_start(); 112 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}') or die('Create db failed'); 113 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 114 | $juapitoken = $_SESSION['sessionjuapitoken']; 115 | if(isset($_POST["JenkinsURL"]) && !empty($_POST["JenkinsURL"])) { 116 | $jurl = $_POST["JenkinsURL"]; 117 | $db->exec("UPDATE UsersExtAPILinks SET JenkinsURL='$jurl' WHERE UserId='$uid' AND JenkinsUserAPIToken='$juapitoken'"); 118 | } 119 | if(isset($_POST["JenkinsAPITokenUserId"]) && !empty($_POST["JenkinsAPITokenUserId"])) { 120 | $juser = $_POST["JenkinsAPITokenUserId"]; 121 | $db->exec("UPDATE UsersExtAPILinks SET JenkinsAPITokenUserId='$juser' WHERE UserId='$uid' AND JenkinsUserAPIToken='$juapitoken'"); 122 | } 123 | if(isset($_POST["JenkinsUserAPIToken"]) && !empty($_POST["JenkinsUserAPIToken"])) { 124 | $newjuapitoken = $_POST["JenkinsUserAPIToken"]; 125 | $db->exec("UPDATE UsersExtAPILinks SET JenkinsUserAPIToken='$newjuapitoken' WHERE UserId='$uid' AND JenkinsUserAPIToken='$juapitoken'"); 126 | } 127 | } 128 | } 129 | if($action == 'edituserinfo') { 130 | if(isset($_POST['Submit'])) { 131 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}') or die('Create db failed'); 132 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 133 | if(isset($_POST['FirstName']) && !empty($_POST['FirstName'])) { 134 | $firstname = $_POST['FirstName']; 135 | $db->exec("UPDATE Users SET FirstName='$firstname' WHERE UserId='$uid'"); 136 | } 137 | if(isset($_POST['LastName']) && !empty($_POST['LastName'])) { 138 | $lastname = $_POST['LastName']; 139 | $db->exec("UPDATE Users SET LastName='$lastname' WHERE UserId='$uid'"); 140 | } 141 | if(isset($_POST['Email']) && !empty($_POST['Email'])) { 142 | $email = $_POST['Email']; 143 | $db->exec("UPDATE Users SET Email='$email' WHERE UserId='$uid'"); 144 | } 145 | if(isset($_POST['Phone']) && !empty($_POST['Phone'])) { 146 | $phone = $_POST['Phone']; 147 | $db->exec("UPDATE Users SET Phone='$phone' WHERE UserId='$uid'"); 148 | } 149 | } 150 | } 151 | if($action == 'viewuserjenkinsapis') { 152 | include 'view_user_jenkins_api.php'; 153 | } 154 | if($action == 'viewuserjenkinsapi') { 155 | if(isset($_POST['Submit'])) { 156 | echo "



"; 157 | echo "

My Jenkins API Token

"; 158 | session_start(); 159 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 160 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 161 | $juapitoken = $_POST['userjenkinsapi']; 162 | $_SESSION['sessionjuapitoken'] = $juapitoken; 163 | $sql = "SELECT * 164 | FROM UsersExtAPILinks 165 | WHERE UserId=$uid AND JenkinsUserAPIToken='$juapitoken'"; 166 | $results = $db->query($sql); 167 | while ($row = $results->fetchArray()) { 168 | echo "
";
169 |         echo "

JenkinsURL:

"; 170 | echo "" . $row['JenkinsURL']. ""; 171 | echo "
"; 172 | echo "
";
173 |         echo "

JenkinsAPITokenUserId:

"; 174 | echo "" . $row['JenkinsAPITokenUserId']. ""; 175 | echo "
"; 176 | echo "
";
177 |         echo "

JenkinsUserAPIToken:

"; 178 | echo "" . $row['JenkinsUserAPIToken']. ""; 179 | echo "
"; 180 | } 181 | include 'edit_user_jenkins_api.php'; 182 | } 183 | } 184 | ?> 185 | -------------------------------------------------------------------------------- /templates/var/www/html/php_details.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | {{ cmdb_web_title }} 16 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /templates/var/www/html/query_group.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 10 | echo ""; 11 | session_start (); 12 | if(isset($_POST['groupid'])) { 13 | $gid = $_POST['groupid']; 14 | } 15 | $_SESSION['sessiongid'] = $gid; 16 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 17 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 18 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 19 | $results = $db->query($sql); 20 | $gn = $db->query("SELECT GroupName FROM Groups WHERE GroupId=$gid"); 21 | while ($row = $results->fetchArray()) { 22 | echo "



"; 23 | echo "

Group Info

"; 24 | echo "
";
25 |       echo "GroupId: ";
26 |       echo "" . $row['GroupId']. "";
27 |       echo "
"; 28 | echo "
";
29 |       echo "GroupName: ";
30 |       echo "" . $row['GroupName']. "
"; 31 | echo "
"; 32 | echo "
";
33 |       echo "GroupDescription: ";
34 |       echo "" . $row['GroupDescription']. "
"; 35 | echo "
"; 36 | echo "
";
37 |       echo "GroupDTAP: ";
38 |       echo "" . $row['GroupDTAP']. "
"; 39 | echo "
"; 40 | echo "
";
41 |       echo "GroupCreatedOn: ";
42 |       echo "" . $row['GroupCreatedOn']. "
"; 43 | echo "
"; 44 | echo "
";
45 |       echo "LastUpdateTime: ";
46 |       echo "" . $row['LastUpdateTime']. "
"; 47 | echo "


"; 48 | } 49 | ?> 50 | 51 | 52 | 53 |
54 |

Group Actions:

69 | 70 | 71 |
72 | 73 | 74 | -------------------------------------------------------------------------------- /templates/var/www/html/query_group_contact_info.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | "; 13 | echo ""; 14 | session_start(); 15 | $gid = $_SESSION['sessiongid']; 16 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 17 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 18 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 19 | $results = $db->query($sql); 20 | while ($row = $results->fetchArray()) { 21 | echo "



"; 22 | echo "

Group Info

"; 23 | echo "
";
24 |             echo "GroupId: ";
25 |             echo "" . $row['GroupId']. "";
26 |             echo "
"; 27 | echo "
";
28 |             echo "GroupName: ";
29 |             echo "" . $row['GroupName']. "
"; 30 | echo "
"; 31 | echo "
";
32 |             echo "GroupDescription: ";
33 |             echo "" . $row['GroupDescription']. "
"; 34 | echo "
"; 35 | echo "
";
36 |             echo "GroupDTAP: ";
37 |             echo "" . $row['GroupDTAP']. "
"; 38 | echo "
"; 39 | echo "
";
40 |             echo "GroupCreatedOn: ";
41 |             echo "" . $row['GroupCreatedOn']. "
"; 42 | echo "
"; 43 | echo "
";
44 |             echo "LastUpdateTime: ";
45 |             echo "" . $row['LastUpdateTime']. "
"; 46 | echo "


"; 47 | } 48 | echo ""; 49 | echo ""; 50 | ?> 51 |

Contacts assigned to group:

52 |
53 | 67 | 68 | 69 |
70 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /templates/var/www/html/query_group_details.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 |



13 |

Check existing groups:

14 |
15 | 27 | 28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /templates/var/www/html/query_group_hosts.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | "; 13 | echo ""; 14 | session_start(); 15 | $gid = $_SESSION['sessiongid']; 16 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 17 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 18 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 19 | $results = $db->query($sql); 20 | while ($row = $results->fetchArray()) { 21 | echo "



"; 22 | echo "

Group Info

"; 23 | echo "
";
24 |             echo "GroupId: ";
25 |             echo "" . $row['GroupId']. "";
26 |             echo "
"; 27 | echo "
";
28 |             echo "GroupName: ";
29 |             echo "" . $row['GroupName']. "
"; 30 | echo "
"; 31 | echo "
";
32 |             echo "GroupDescription: ";
33 |             echo "" . $row['GroupDescription']. "
"; 34 | echo "
"; 35 | echo "
";
36 |             echo "GroupDTAP: ";
37 |             echo "" . $row['GroupDTAP']. "
"; 38 | echo "
"; 39 | echo "
";
40 |             echo "GroupCreatedOn: ";
41 |             echo "" . $row['GroupCreatedOn']. "
"; 42 | echo "
"; 43 | echo "
";
44 |             echo "LastUpdateTime: ";
45 |             echo "" . $row['LastUpdateTime']. "
"; 46 | echo "


"; 47 | } 48 | echo ""; 49 | echo ""; 50 | ?> 51 |

Hosts assigned to group:

52 |
53 | 67 | 68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /templates/var/www/html/query_host_details.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 10 | echo ""; 11 | session_start (); 12 | if(isset($_POST['groupid'])) { 13 | $gid = $_POST['groupid']; 14 | } 15 | $gid = $_SESSION['sessiongid']; 16 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 17 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 18 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 19 | $results = $db->query($sql); 20 | $gn = $db->query("SELECT GroupName FROM Groups WHERE GroupId=$gid"); 21 | while ($row = $results->fetchArray()) { 22 | echo "



"; 23 | echo "

Group Info

"; 24 | echo "
";
 25 |         echo "GroupId: ";
 26 |         echo "" . $row['GroupId']. "";
 27 |         echo "
"; 28 | echo "
";
 29 |         echo "GroupName: ";
 30 |         echo "" . $row['GroupName']. "
"; 31 | echo "
"; 32 | echo "
";
 33 |         echo "GroupDescription: ";
 34 |         echo "" . $row['GroupDescription']. "
"; 35 | echo "
"; 36 | echo "
";
 37 |         echo "GroupDTAP: ";
 38 |         echo "" . $row['GroupDTAP']. "
"; 39 | echo "
"; 40 | echo "
";
 41 |         echo "GroupCreatedOn: ";
 42 |         echo "" . $row['GroupCreatedOn']. "
"; 43 | echo "
"; 44 | echo "
";
 45 |         echo "LastUpdateTime: ";
 46 |         echo "" . $row['LastUpdateTime']. "
"; 47 | echo "


"; 48 | } 49 | echo ""; 50 | echo ""; 51 | ?> 52 | exec( 'PRAGMA foreign_keys = ON;' ); 63 | $hn = $db->querySingle("SELECT HostName FROM Hosts WHERE HostId=$hid"); 64 | $_SESSION['sessionhn'] = $hn; 65 | echo "
"; 66 | echo "

Host Actions:

"; 71 | echo ""; 72 | echo ""; 73 | echo "
"; 74 | } 75 | ?> 76 | exec( 'PRAGMA foreign_keys = ON;' ); 88 | $sql = "SELECT * FROM HostDetails WHERE HostId=$hid"; 89 | $results = $db->query($sql); 90 | echo "

Details about host:

"; 91 | while ($row = $results->fetchArray()) { 92 | echo "
";
 93 |         echo "hostId: ";
 94 |         echo "" . $row['HostId']. "";
 95 |         echo "
"; 96 | echo "
";
 97 |         echo "FQDN: ";
 98 |         echo "" . $row['HostFQDN']. "
"; 99 | echo "
"; 100 | echo "
";
101 |         echo "Architecture: ";
102 |         echo "" . $row['HostArchitecture']. "";
103 |         echo "
"; 104 | echo "
";
105 |         echo "BIOSDate: ";
106 |         echo "" . $row['HostBIOSDate']. "";
107 |         echo "
"; 108 | echo "
";
109 |         echo "BIOSVersion: ";
110 |         echo "" . $row['HostBIOSVersion']. "";
111 |         echo "
"; 112 | echo "
";
113 |         echo "Distribution: ";
114 |         echo "" . $row['HostDistribution']. "";
115 |         echo "
"; 116 | echo "
";
117 |         echo "DistributionRelease: ";
118 |         echo "" . $row['HostDistributionRelease']. "";
119 |         echo "
"; 120 | echo "
";
121 |         echo "DistributionVersion: ";
122 |         echo "" . $row['HostDistributionVersion']. "";
123 |         echo "
"; 124 | echo "
";
125 |         echo "HardDrive: ";
126 |         echo "" . $row['HostHardDrive']. "";
127 |         echo "
"; 128 | echo "
";
129 |         echo "HardDrivePartions: ";
130 |         echo "" . $row['HostHardDrivePartions']. "";
131 |         echo "
"; 132 | echo "
";
133 |         echo "HardDriveSize: ";
134 |         echo "" . $row['HostHardDriveSize']. "";
135 |         echo "
"; 136 | echo "
";
137 |         echo "Interface: ";
138 |         echo "" . $row['HostInterface']. "";
139 |         echo "
"; 140 | echo "
";
141 |         echo "InterfaceAddress: ";
142 |         echo "" . $row['HostInterfaceAddress']. "";
143 |         echo "
"; 144 | echo "
";
145 |         echo "InterfaceGateway: ";
146 |         echo "" . $row['HostInterfaceGateway']. "";
147 |         echo "
"; 148 | echo "
";
149 |         echo "InterfaceMAC: ";
150 |         echo "" . $row['HostInterfaceMAC']. "";
151 |         echo "
"; 152 | echo "
";
153 |         echo "InterfaceNetmask: ";
154 |         echo "" . $row['HostInterfaceNetmask']. "";
155 |         echo "
"; 156 | echo "
";
157 |         echo "Kernel: ";
158 |         echo "" . $row['HostKernel']. "";
159 |         echo "
"; 160 | echo "
";
161 |         echo "MemFreeMB: ";
162 |         echo "" . $row['HostMemFreeMB']. "";
163 |         echo "
"; 164 | echo "
";
165 |         echo "MemTotalMB: ";
166 |         echo "" . $row['HostMemTotalMB']. "";
167 |         echo "
"; 168 | echo "
";
169 |         echo "Mounts: ";
170 |         echo "" . $row['HostMounts']. "";
171 |         echo "
"; 172 | echo "
";
173 |         echo "OSFamily: ";
174 |         echo "" . $row['HostOSFamily']. "";
175 |         echo "
"; 176 | echo "
";
177 |         echo "Processor: ";
178 |         echo "" . $row['HostProcessor']. "";
179 |         echo "
"; 180 | echo "
";
181 |         echo "ProcessorCores: ";
182 |         echo "" . $row['HostProcessorCores']. "";
183 |         echo "
"; 184 | echo "
";
185 |         echo "ProcessorCount: ";
186 |         echo "" . $row['HostProcessorCount']. "";
187 |         echo "
"; 188 | echo "
";
189 |         echo "ProductName: ";
190 |         echo "" . $row['HostProductName']. "";
191 |         echo "
"; 192 | echo "
";
193 |         echo "SwapFree: ";
194 |         echo "" . $row['HostSwapFree']. "";
195 |         echo "
"; 196 | echo "
";
197 |         echo "SwapTotal: ";
198 |         echo "" . $row['HostSwapTotal']. "";
199 |         echo "
"; 200 | echo "
";
201 |         echo "SystemVendor: ";
202 |         echo "" . $row['HostSystemVendor']. "";
203 |         echo "
"; 204 | echo "
";
205 |         echo "TimeZone: ";
206 |         echo "" . $row['HostTimeZone']. "";
207 |         echo "
"; 208 | echo "
";
209 |         echo "VirtualizationType: ";
210 |         echo "" . $row['HostVirtualizationType']. "";
211 |         echo "
"; 212 | echo "
";
213 |         echo "LastUpdateTime: ";
214 |         echo "" . $row['LastUpdateTime']. "";
215 |         echo "
"; 216 | } 217 | } 218 | if ($ha=="ViewLogs") { 219 | session_start(); 220 | $hn = $_SESSION['sessionhn']; 221 | echo ""; 222 | echo ""; 223 | echo "

"; 224 | echo ""; 225 | echo ""; 226 | } 227 | } 228 | ?> 229 | -------------------------------------------------------------------------------- /templates/var/www/html/query_users.php.j2: -------------------------------------------------------------------------------- 1 | 8 | exec( 'PRAGMA foreign_keys = ON;' ); 11 | $sql = "SELECT UserName FROM Users"; 12 | $results = $db->query($sql); 13 | while ($row = $results->fetchArray()) { 14 | echo ''; 15 | } 16 | ?> 17 | -------------------------------------------------------------------------------- /templates/var/www/html/register_user.php.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 80 | 81 | 82 | exec( 'PRAGMA foreign_keys = ON;' ); 93 | $sql = "INSERT INTO Users 94 | (UserName,Email,FirstName,LastName,Password,Phone) 95 | VALUES ('$username','$email','$firstname','$lastname','$hash','$phone')"; 96 | if (empty($username)) { 97 | echo "
";
 98 |         echo "Username was not entered..";
 99 |         echo "
"; 100 | } 101 | if (empty($firstname)) { 102 | echo "
";
103 |         echo "First name was not entered..";
104 |         echo "
"; 105 | } 106 | if (empty($lastname)) { 107 | echo "
";
108 |         echo "Last name was not entered..";
109 |         echo "
"; 110 | } 111 | if (empty($email)) { 112 | echo "
";
113 |         echo "Email was not entered..";
114 |         echo "
"; 115 | } 116 | if (empty($password)) { 117 | echo "
";
118 |         echo "Password was not entered..";
119 |         echo "
"; 120 | } 121 | if (!empty($username) && !empty($firstname) && !empty($lastname) && !empty($email) && !empty($password)) { 122 | $db->exec($sql); 123 | echo "User $username has been created."; 124 | header("Location: index.php"); 125 | exit; 126 | } 127 | } 128 | ?> 129 |

(** - Required)

130 |
131 | Username: (**)

132 | Password: (**)

133 | First name: (**)

134 | Last name: (**)

135 | Email: (**)

136 | Phone:

137 | 138 | 139 |
140 |
141 |

Home | Login

142 |
143 | 144 | 145 | -------------------------------------------------------------------------------- /templates/var/www/html/run_group_ansible_playbook.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 10 | echo ""; 11 | session_start (); 12 | $gid = $_SESSION['sessiongid']; 13 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 14 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 15 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 16 | $results = $db->query($sql); 17 | $gn = $db->query("SELECT GroupName FROM Groups WHERE GroupId=$gid"); 18 | while ($row = $results->fetchArray()) { 19 | echo "



"; 20 | echo "

Group Info

"; 21 | echo "
";
22 |       echo "GroupId: ";
23 |       echo "" . $row['GroupId']. "";
24 |       echo "
"; 25 | echo "
";
26 |       echo "GroupName: ";
27 |       echo "" . $row['GroupName']. "
"; 28 | echo "
"; 29 | echo "
";
30 |       echo "GroupDescription: ";
31 |       echo "" . $row['GroupDescription']. "
"; 32 | echo "
"; 33 | echo "
";
34 |       echo "GroupDTAP: ";
35 |       echo "" . $row['GroupDTAP']. "
"; 36 | echo "
"; 37 | echo "
";
38 |       echo "GroupCreatedOn: ";
39 |       echo "" . $row['GroupCreatedOn']. "
"; 40 | echo "
"; 41 | echo "
";
42 |       echo "LastUpdateTime: ";
43 |       echo "" . $row['LastUpdateTime']. "
"; 44 | echo "


"; 45 | } 46 | ?> 47 | 48 | 49 | 50 |

Ansible Playbooks:

51 |
52 | 66 | 67 |
68 | 69 | 70 | -------------------------------------------------------------------------------- /templates/var/www/html/send_group_email.html.j2: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ cmdb_web_title }} 9 | 24 | 25 | 26 | "; 28 | echo ""; 29 | session_start(); 30 | $gid = $_SESSION['sessiongid']; 31 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 32 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 33 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 34 | $results = $db->query($sql); 35 | while ($row = $results->fetchArray()) { 36 | echo "
";
37 |           echo "GroupId: ";
38 |           echo "" . $row['GroupId']. "";
39 |           echo "
"; 40 | echo "
";
41 |           echo "GroupName: ";
42 |           echo "" . $row['GroupName']. "
"; 43 | echo "
"; 44 | echo "
";
45 |           echo "GroupDescription: ";
46 |           echo "" . $row['GroupDescription']. "
"; 47 | echo "
"; 48 | echo "
";
49 |           echo "GroupDTAP: ";
50 |           echo "" . $row['GroupDTAP']. "
"; 51 | echo "
"; 52 | echo "
";
53 |           echo "GroupCreatedOn: ";
54 |           echo "" . $row['GroupCreatedOn']. "
"; 55 | echo "
"; 56 | echo "
";
57 |           echo "LastUpdateTime: ";
58 |           echo "" . $row['LastUpdateTime']. "
"; 59 | echo "


"; 60 | } 61 | echo ""; 62 | echo ""; 63 | ?> 64 | 68 |
69 | Subject:
70 |
71 | Message:
72 |
73 | 74 | 75 |
76 | 77 | 78 | -------------------------------------------------------------------------------- /templates/var/www/html/send_group_email.php.j2: -------------------------------------------------------------------------------- 1 | 8 | "; 11 | echo ""; 12 | session_start(); 13 | $gid = $_SESSION['sessiongid']; 14 | $email_message = $_POST["email_message"]; 15 | $email_subject = $_POST["email_subject"]; 16 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 17 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 18 | $sql = "SELECT * FROM GroupContact WHERE GroupId=$gid"; 19 | $results = $db->query($sql); 20 | while ($row = $results->fetchArray()) { 21 | $to = $row['ContactEmail']; 22 | $subject = "$email_subject"; 23 | $message = "$email_message"; 24 | $header = "From:{{ cmdb_notifications_from_email_address }} \r\n"; 25 | $header .= "MIME-Version: 1.0\r\n"; 26 | $header .= "Content-type: text/html\r\n"; 27 | $retval = mail ($to,$subject,$message,$header); 28 | if( $retval == true ) 29 | { 30 | echo "
";
31 |           echo "Message sent successfully to $to";
32 |           echo "
"; 33 | } 34 | else 35 | { 36 | echo "Message could not be sent..."; 37 | } 38 | } 39 | echo ""; 40 | echo "

"; 41 | } 42 | ?> 43 | "; 45 | echo ""; 46 | session_start(); 47 | $gid = $_SESSION['sessiongid']; 48 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 49 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 50 | $sql = "SELECT * FROM Groups WHERE GroupId=$gid"; 51 | $results = $db->query($sql); 52 | while ($row = $results->fetchArray()) { 53 | echo "



"; 54 | echo "
";
55 |       echo "GroupId: ";
56 |       echo "" . $row['GroupId']. "";
57 |       echo "
"; 58 | echo "
";
59 |       echo "GroupName: ";
60 |       echo "" . $row['GroupName']. "
"; 61 | echo "
"; 62 | echo "
";
63 |       echo "GroupDescription: ";
64 |       echo "" . $row['GroupDescription']. "
"; 65 | echo "
"; 66 | echo "
";
67 |       echo "GroupDTAP: ";
68 |       echo "" . $row['GroupDTAP']. "
"; 69 | echo "
"; 70 | echo "
";
71 |       echo "GroupCreatedOn: ";
72 |       echo "" . $row['GroupCreatedOn']. "
"; 73 | echo "
"; 74 | echo "
";
75 |       echo "LastUpdateTime: ";
76 |       echo "" . $row['LastUpdateTime']. "
"; 77 | echo "


"; 78 | } 79 | echo ""; 80 | echo ""; 81 | ?> 82 | 83 | 84 |
85 | Subject:
86 |
87 | Message:
88 |
89 | 90 | 91 |
92 | 93 | 94 | -------------------------------------------------------------------------------- /templates/var/www/html/validate_login.php.j2: -------------------------------------------------------------------------------- 1 | exec( 'PRAGMA foreign_keys = ON;' ); 12 | $sql = "SELECT UserId,UserName,Password 13 | FROM Users 14 | WHERE UserName='$username' 15 | LIMIT 1"; 16 | $results = $db->query($sql) or die('Query failed'); 17 | // Credentials match so we create session variables 18 | while ($row = $results->fetchArray()) { 19 | if (password_verify($_POST['password'], $row['Password'])) { 20 | $_SESSION['UserId'] = $row['UserId']; 21 | $_SESSION['UserName'] = $row['UserName']; 22 | $_SESSION['user_is_logged_in'] = true; 23 | // After assigning the session variables, 24 | // set the url to redirect the user to members page. 25 | $url = 'index.php'; 26 | } 27 | else { 28 | // If not, then redirect the user the login page with an error 29 | $url = 'login.php?error=true'; 30 | } 31 | } 32 | } 33 | if(!isset($_POST['username']) && !isset($_POST['password'])) { 34 | // If login information not sent redirect back to login page 35 | $url = 'login.php?error=true'; 36 | } 37 | if(isset($url)) { 38 | header("Location: $url"); 39 | exit; 40 | } 41 | if(!isset($url)) { 42 | header("Location: index.php"); 43 | exit; 44 | } 45 | ?> 46 | -------------------------------------------------------------------------------- /templates/var/www/html/view_group_contact_info.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | "; 13 | echo ""; 14 | session_start(); 15 | $cid = $_POST['contactid']; 16 | $gid = $_SESSION['sessiongid']; 17 | $db = new SQLite3('{{ cmdb_sqlite_db_file }}'); 18 | $db->exec( 'PRAGMA foreign_keys = ON;' ); 19 | $sql = "SELECT * FROM GroupContact WHERE ContactId=$cid"; 20 | $results = $db->query($sql); 21 | while ($row = $results->fetchArray()) { 22 | echo "



"; 23 | echo "
";
24 |             echo "ContactId: ";
25 |             echo "" . $row['ContactId']. "";
26 |             echo "
"; 27 | echo "
";
28 |             echo "ContactName: ";
29 |             echo "" . $row['ContactName']. "
"; 30 | echo "
"; 31 | echo "
";
32 |             echo "ContactEmail: ";
33 |             echo "" . $row['ContactEmail']. "
"; 34 | echo "
"; 35 | echo "
";
36 |             echo "ContactPhone: ";
37 |             echo "" . $row['ContactPhone']. "
"; 38 | echo "
"; 39 | echo "
";
40 |             echo "ContactCreatedOn: ";
41 |             echo "" . $row['ContactCreatedOn']. "
"; 42 | echo "
"; 43 | echo "
";
44 |             echo "LastUpdateTime: ";
45 |             echo "" . $row['LastUpdateTime']. "
"; 46 | echo "


"; 47 | } 48 | echo "
"; 49 | echo "Contact Actions:
"; 55 | echo ""; 56 | echo ""; 57 | echo "
"; 58 | echo ""; 59 | echo ""; 60 | ?> 61 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /templates/var/www/html/view_user_jenkins_api.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 |



12 |

My Jenkins API Access Tokens

13 |
14 | 29 | 30 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /templates/var/www/html/view_user_links.php.j2: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 |



12 |

My Custom Links

13 |
14 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /tests/inventory: -------------------------------------------------------------------------------- 1 | localhost -------------------------------------------------------------------------------- /tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - ansible-cmdb -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for ansible-cmdb 3 | --------------------------------------------------------------------------------