diff --git a/roles/role_deploy_mysql-server/README.md b/roles/role_deploy_mysql-server/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/role_deploy_mysql-server/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/role_deploy_mysql-server/defaults/main.yml b/roles/role_deploy_mysql-server/defaults/main.yml new file mode 100644 index 0000000..9d3a4cf --- /dev/null +++ b/roles/role_deploy_mysql-server/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for role_deploy_mysql-server diff --git a/roles/role_deploy_mysql-server/handlers/main.yml b/roles/role_deploy_mysql-server/handlers/main.yml new file mode 100644 index 0000000..8676ac8 --- /dev/null +++ b/roles/role_deploy_mysql-server/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for role_deploy_mysql-server diff --git a/roles/role_deploy_mysql-server/meta/main.yml b/roles/role_deploy_mysql-server/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/role_deploy_mysql-server/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/tasks/deploy_mysql-server.yml b/roles/role_deploy_mysql-server/tasks/main.yml similarity index 94% rename from tasks/deploy_mysql-server.yml rename to roles/role_deploy_mysql-server/tasks/main.yml index f93dff3..4d23807 100644 --- a/tasks/deploy_mysql-server.yml +++ b/roles/role_deploy_mysql-server/tasks/main.yml @@ -8,7 +8,7 @@ failed_when: "result_mysql_server_systemd_stop is failed and 'Could not find the requested service' not in result_mysql_server_systemd_stop.msg" - name: Check if mysql-server container is running - command: 'podman ps -q --filter "name=mysql-server"' + command: 'podman ps -q --filter "name=^mysql-server$"' changed_when: false register: podman_ps become: true @@ -58,9 +58,7 @@ - --skip_name_resolve state: present network: - - mysqlnet - # We need to fix the IP address because podman DNS does not work with an internal network. - ip: 10.89.1.2 + - host volume: - /mnt/volumes/mysql-server_data/data:/var/lib/mysql:z - /mnt/volumes/mysql-server_dumps/data:/mnt/dumps:z @@ -87,6 +85,10 @@ containers.podman.podman_container_exec: name: mysql-server command: "bash -c 'mariadb-upgrade --force -u root -p{{ mysql_root_ovh1.password }}'" + register: mariadb_upgrade + until: "mariadb_upgrade is not failed" + retries: 3 + delay: 5 become: true when: create_mysql_container is changed @@ -96,4 +98,3 @@ state: restarted become: true when: create_mysql_container is changed - diff --git a/tasks/mysql-server_install_from_backup_stage_1.yml b/roles/role_deploy_mysql-server/tasks/mysql-server_install_from_backup_stage_1.yml similarity index 81% rename from tasks/mysql-server_install_from_backup_stage_1.yml rename to roles/role_deploy_mysql-server/tasks/mysql-server_install_from_backup_stage_1.yml index e817a00..6910473 100644 --- a/tasks/mysql-server_install_from_backup_stage_1.yml +++ b/roles/role_deploy_mysql-server/tasks/mysql-server_install_from_backup_stage_1.yml @@ -1,15 +1,4 @@ --- -- name: Create mysqlnet network - containers.podman.podman_network: - name: mysqlnet - # We do not need to publish ports from this network - # and publishing ports on containers that are attached to mysqlnet - # and other networks will not work unless all networks but one are internal. - internal: true - # We need to fix the subnet because podman DNS does not work with an internal network. - subnet: 10.89.1.0/24 - become: true - - name: Create /usr/local/docker-mounted-files/docker-mysql-server-stack directory ansible.builtin.file: path: "/usr/local/docker-mounted-files/docker-mysql-server-stack" @@ -25,7 +14,7 @@ with_items: - debian.cnf - # A local volume is needed where other stacks will be able to copy scripts +# A local volume is needed where other stacks will be able to copy scripts - name: Create /mnt/volumes/mysql-server_scripts directory ansible.builtin.file: path: "/mnt/volumes/mysql-server_scripts" diff --git a/tasks/mysql-server_install_from_backup_stage_2.yml b/roles/role_deploy_mysql-server/tasks/mysql-server_install_from_backup_stage_2.yml similarity index 100% rename from tasks/mysql-server_install_from_backup_stage_2.yml rename to roles/role_deploy_mysql-server/tasks/mysql-server_install_from_backup_stage_2.yml diff --git a/tasks/mysql-server_install_from_backup_stage_3.yml b/roles/role_deploy_mysql-server/tasks/mysql-server_install_from_backup_stage_3.yml similarity index 100% rename from tasks/mysql-server_install_from_backup_stage_3.yml rename to roles/role_deploy_mysql-server/tasks/mysql-server_install_from_backup_stage_3.yml diff --git a/roles/role_deploy_mysql-server/tests/inventory b/roles/role_deploy_mysql-server/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/role_deploy_mysql-server/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/role_deploy_mysql-server/tests/test.yml b/roles/role_deploy_mysql-server/tests/test.yml new file mode 100644 index 0000000..5690049 --- /dev/null +++ b/roles/role_deploy_mysql-server/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - role_deploy_mysql-server diff --git a/roles/role_deploy_mysql-server/vars/main.yml b/roles/role_deploy_mysql-server/vars/main.yml new file mode 100644 index 0000000..c5413ec --- /dev/null +++ b/roles/role_deploy_mysql-server/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for role_deploy_mysql-server