diff --git a/Databases-templates/mysql-play.tpl b/Databases-templates/mysql-play.tpl index fcbfa712191d80ce3556782264d0a110c8649fa9..df0de7ba12c883f26373cd0b6a1f278729f82620 100644 --- a/Databases-templates/mysql-play.tpl +++ b/Databases-templates/mysql-play.tpl @@ -6,14 +6,9 @@ pre_tasks: - name: Install MySQL - apt: name={{ item }} update_cache=yes cache_valid_time=3600 state=present + ###OS###: name={{ item }} update_cache=yes cache_valid_time=3600 state=present with_items: - - mysql-server - - mysql-client - - python-setuptools - - python-mysqldb - - libmysqlclient-dev - - python3-pip +###OS_PACKETS### - name: Remove a symbolic link ansible.builtin.file: diff --git a/ansibleBuilder.py b/ansibleBuilder.py index 880d5ffcfcc255bab604bc49511f1c438366f784..424ef7016ed0ef269814a6e5795c3cf858c2e63b 100644 --- a/ansibleBuilder.py +++ b/ansibleBuilder.py @@ -33,6 +33,8 @@ class AnsibleModule: def edit_template(self, template_type, template_list, template_data, kind): if template_type == "postgres": new_file = ansibleUtils.databases_postgres(template_list, template_data, kind) + if template_type == "mysql": + new_file = ansibleUtils.databases_mysql(template_list, template_data, kind) if template_type == "wordpress": new_file = ansibleUtils.service_wordpress(template_list, template_data, kind) return new_file diff --git a/ansibleUtils.py b/ansibleUtils.py index c43cf11e1b0e3a0b18bd7aac2ab282c57813ac99..dbfe787322b28405424dcf6274c182a93c259d0f 100644 --- a/ansibleUtils.py +++ b/ansibleUtils.py @@ -20,6 +20,17 @@ def databases_postgres(template_list, template_data, kind): new_template_list = generic_matcher(template_list, specific_data) return "".join(new_template_list) +def databases_mysql(template_list, template_data, kind): + if kind == "vars": + new_template_list = generic_matcher(template_list, template_data[kind]) + if kind == "play": + if template_data[kind]["OS"] == "debian": + specific_data = {"OS": "apt", "OS_PACKETS": " - mysql-server\n - mysql-client\n - python-setuptools\n - python-mysqldb\n - libmysqlclient-dev\n - python3-pip"} + elif template_data[kind]["OS"] == "centos": + specific_data = {"OS": "yum", "OS_PACKETS": " - postgresql10\n - postgresql10-server\n - postgresql10-contrib\n - postgresql10-libs"} + new_template_list = generic_matcher(template_list, specific_data) + return "".join(new_template_list) + def service_wordpress(template_list, template_data, kind): if kind == "vars": new_template_list = generic_matcher(template_list, template_data[kind]) diff --git a/parameters.json b/parameters.json index f7b72cc569d11fd091ea5df48375ac9c4490f660..cb5f45ba6667dbaa97efa65622fcf204a147f26f 100644 --- a/parameters.json +++ b/parameters.json @@ -44,7 +44,7 @@ "type":"database", "output_path": "Output-code/", "info" : { - "name" : "postgres", + "name" : "mysql", "template_path" : "Databases-templates/" }, "data":{