Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev rds ssl #392

Draft
wants to merge 19 commits into
base: rocky-develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@
magento_core_config_settings: "{{ magento_core_config_settings + magento_baler_js_bundling_core_config }}"
when: magento_scd_advanced_js_bundling and magento_scd_advanced_js_bundling_strategy == 'baler'

- name: Download CA RDS
ansible.builtin.get_url:
url: https://truststore.pki.rds.amazonaws.com/eu-central-1/eu-central-1-bundle.pem
dest: /tmp/eu-central-1-bundle.pem
mode: '0666'

- name: Check if database is initialized
command: mysql -N --batch -u {{ mageops_app_mysql_user|quote }} -p{{ mageops_app_mysql_pass|quote }} -h {{ mageops_mysql_host|quote }} -e "SHOW TABLES FROM `{{ mageops_app_mysql_db }}` LIKE 'admin_user';"
command: mysql --ssl-ca=/tmp/eu-central-1-bundle.pem -N --batch -u {{ mageops_app_mysql_user|quote }} -p{{ mageops_app_mysql_pass|quote }} -h {{ mageops_mysql_host|quote }} -e "SHOW TABLES FROM `{{ mageops_app_mysql_db }}` LIKE 'admin_user';"
changed_when: false
register: admins

Expand Down
11 changes: 11 additions & 0 deletions roles/cs.magento-configure/tasks/080-core-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
magento_core_config_settings: "{{ magento_core_config_settings + _extra_items }}"
when: magento_varnish_host | default(false, true)

- name: Download CA RDS
ansible.builtin.get_url:
url: https://truststore.pki.rds.amazonaws.com/eu-central-1/eu-central-1-bundle.pem
dest: /tmp/eu-central-1-bundle.pem
mode: '0666'


- name: Ensure core config database settings' values
community.mysql.mysql_query:
login_db: "{{ mageops_app_mysql_db }}"
login_host: "{{ mageops_mysql_host }}"
login_user: "{{ mageops_app_mysql_user }}"
login_password: "{{ mageops_app_mysql_pass }}"
ca_cert: /tmp/eu-central-1-bundle.pem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not store permament files in temp

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make that confirurable and resonable

query: |
INSERT INTO `core_config_data`
SET
Expand All @@ -35,6 +43,7 @@
login_host: "{{ mageops_mysql_host }}"
login_user: "{{ mageops_app_mysql_user }}"
login_password: "{{ mageops_app_mysql_pass }}"
ca_cert: /tmp/eu-central-1-bundle.pem
query: |
INSERT IGNORE INTO `core_config_data`
SET
Expand All @@ -47,12 +56,14 @@
loop_control:
loop_var: magento_db_setting


- name: Ensure core config database settings are absent (defaults are used)
community.mysql.mysql_query:
login_db: "{{ mageops_app_mysql_db }}"
login_host: "{{ mageops_mysql_host }}"
login_user: "{{ mageops_app_mysql_user }}"
login_password: "{{ mageops_app_mysql_pass }}"
ca_cert: /tmp/eu-central-1-bundle.pem
query: |
DELETE FROM core_config_data
WHERE
Expand Down
9 changes: 9 additions & 0 deletions roles/cs.mysql-configure/tasks/create-db.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
- name: Download CA RDS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is downloaded so many times. Why? Cant we just download it once ? Or check if it does not exists?

ansible.builtin.get_url:
url: https://truststore.pki.rds.amazonaws.com/eu-central-1/eu-central-1-bundle.pem
dest: /tmp/eu-central-1-bundle.pem
mode: '0666'

- name: Ensure project database exists
mysql_db:
login_host: "{{ mageops_mysql_host }}"
login_user: "{{ mageops_mysql_root_user }}"
login_password: "{{ mageops_mysql_root_pass }}"
name: "{{ mageops_app_mysql_db }}"
state: present
ca_cert: /tmp/eu-central-1-bundle.pem

- name: Ensure project db user for external connections exists
mysql_user:
Expand All @@ -15,6 +22,7 @@
password: "{{ mageops_app_mysql_pass }}"
host: "%"
state: present
ca_cert: /tmp/eu-central-1-bundle.pem
priv: "{{ mageops_app_mysql_db }}.*:{{ mysql_configure_all_db_permissions }}"

- name: Ensure project db user for localhost exists
Expand All @@ -26,5 +34,6 @@
password: "{{ mageops_app_mysql_pass }}"
host: "localhost"
state: present
ca_cert: /tmp/eu-central-1-bundle.pem
priv: "{{ mageops_app_mysql_db }}.*:{{ mysql_configure_all_db_permissions }}"
when: mysql_user_localhost_access