From f4d1b12c5ba04b89bd2a294ef0ecac37a88fc8e7 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sun, 19 Jan 2025 19:01:37 -0500 Subject: [PATCH] added inventory finsing --- ANSIBLE/env | 69 ----------------------------------- ANSIBLE/templates/A000003.yml | 21 ++++++++++- ANSIBLE/templates/README.md | 15 ++++++++ app/Controllers/Home.php | 10 ++++- 4 files changed, 43 insertions(+), 72 deletions(-) delete mode 100644 ANSIBLE/env diff --git a/ANSIBLE/env b/ANSIBLE/env deleted file mode 100644 index f359ec2..0000000 --- a/ANSIBLE/env +++ /dev/null @@ -1,69 +0,0 @@ -#-------------------------------------------------------------------- -# Example Environment Configuration file -# -# This file can be used as a starting point for your own -# custom .env files, and contains most of the possible settings -# available in a default install. -# -# By default, all of the settings are commented out. If you want -# to override the setting, you must un-comment it by removing the '#' -# at the beginning of the line. -#-------------------------------------------------------------------- - -#-------------------------------------------------------------------- -# ENVIRONMENT -#-------------------------------------------------------------------- - -# CI_ENVIRONMENT = production - -#-------------------------------------------------------------------- -# APP -#-------------------------------------------------------------------- - -# app.baseURL = '' -# If you have trouble with `.`, you could also use `_`. -# app_baseURL = '' -# app.forceGlobalSecureRequests = false -# app.CSPEnabled = false - -#-------------------------------------------------------------------- -# DATABASE -#-------------------------------------------------------------------- - -# database.default.hostname = localhost -# database.default.database = ci4 -# database.default.username = root -# database.default.password = root -# database.default.DBDriver = MySQLi -# database.default.DBPrefix = -# database.default.port = 3306 - -# If you use MySQLi as tests, first update the values of Config\Database::$tests. -# database.tests.hostname = localhost -# database.tests.database = ci4_test -# database.tests.username = root -# database.tests.password = root -# database.tests.DBDriver = MySQLi -# database.tests.DBPrefix = -# database.tests.charset = utf8mb4 -# database.tests.DBCollat = utf8mb4_general_ci -# database.tests.port = 3306 - -#-------------------------------------------------------------------- -# ENCRYPTION -#-------------------------------------------------------------------- - -# encryption.key = - -#-------------------------------------------------------------------- -# SESSION -#-------------------------------------------------------------------- - -# session.driver = 'CodeIgniter\Session\Handlers\FileHandler' -# session.savePath = null - -#-------------------------------------------------------------------- -# LOGGER -#-------------------------------------------------------------------- - -# logger.threshold = 4 diff --git a/ANSIBLE/templates/A000003.yml b/ANSIBLE/templates/A000003.yml index 50fb5ac..84b3c4a 100644 --- a/ANSIBLE/templates/A000003.yml +++ b/ANSIBLE/templates/A000003.yml @@ -1 +1,20 @@ -A000003 \ No newline at end of file +--- +- hosts: WHAT_HOST_IN_USE + vars_files: + - vars/main.yml + + tasks: + - name: Set up docker-compose file + template: + src: "files/docker-compose.yml" + dest: "/home/{{ admin_user }}/wordpress/" + + - name: Set permission for docker daemon + file: + path: /var/run/docker.sock + mode: '0770' + + - name: docker compose up + shell: + chdir: "/home/{{ admin_user }}/wordpress/" + cmd: docker-compose up -d \ No newline at end of file diff --git a/ANSIBLE/templates/README.md b/ANSIBLE/templates/README.md index 1149055..f5d8db9 100644 --- a/ANSIBLE/templates/README.md +++ b/ANSIBLE/templates/README.md @@ -10,3 +10,18 @@ Personal Blog | A000003 | 5 (5 rows) +https://dev.to/nithinalias/docker-compose-install-wordpress-using-ansible-2lnh + + +[web_servers] +172.16.250.132 +172.16.250.248 + +[db_servers] +172.16.250.133 + +[file_servers] +172.16.250.134 + + +https://www.learnlinux.tv/getting-started-with-ansible-09-targeting-specific-nodes/ \ No newline at end of file diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 561d95f..36a0d25 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -20,12 +20,18 @@ class Home extends BaseController //$provision_list =[]; foreach ($provision_list as $pr){ + $productId = $pr->product_id; + $prov_name = str_replace(".", "_", $pr->internal_url).".yml"; $template_file = $ansible_folder ."/templates/".$pr->product_id.".yml"; - $template_content = file_get_contents($template_file); + // GET THE TEMPLATE FOR THIS PROVISIONING + $template_content = file_get_contents($template_file); + $template_content_processed = str_replace("WHAT_HOST_IN_USE", $productId."_SERVER", $template_content);; + + // CREATE PROVISOINING FILE $myfile = fopen( $ansible_folder ."/".$prov_name, "w") or die("Unable to open file!"); - fwrite($myfile, $template_content); + fwrite($myfile, $template_content_processed); fclose($myfile); }