--- - name: gather os specific variables include_vars: "{{ item }}" with_first_found: - files: - "{{ ansible_distribution | lower | regex_replace('[^a-zA-Z0-9 ]+|[ ]+$', '') |replace(' ','_') | lower}}-{{ansible_distribution_release}}.yml" - "{{ ansible_distribution | lower | regex_replace('[^a-zA-Z0-9 ]+|[ ]+$', '') |replace(' ','_') | lower}}.yml" - "{{ ansible_distribution | lower | replace(' ', '_') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.{{ ansible_architecture }}.yml" - "{{ ansible_distribution | lower | replace(' ', '_') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml" - "{{ ansible_distribution | lower | replace(' ', '_') }}-{{ ansible_distribution_release|lower }}-{{ ansible_architecture }}.yml" - "{{ ansible_distribution | lower | replace(' ', '_') }}-{{ ansible_distribution_release|lower }}.yml" - "{{ ansible_distribution | lower | replace(' ', '_') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml" - "{{ ansible_distribution | lower | replace(' ', '_') }}-{{ ansible_architecture }}.yml" - "{{ ansible_distribution | lower | replace(' ', '_') }}.yml" - "{{ ansible_os_family|lower }}-{{ ansible_architecture }}.yml" - "{{ ansible_os_family|lower }}.yml" - defaults.yml - name: Include Pre Install tasks if any include_tasks: "{{ item }}" with_first_found: - files: - "pre-{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.{{ ansible_architecture }}.yml" - "pre-{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml" - "pre-{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_release|lower }}-{{ ansible_architecture }}.yml" - "pre-{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_release|lower }}.yml" - "pre-{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml" - "pre-{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_architecture }}.yml" - "pre-{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}.yml" - "pre-{{ ansible_os_family|lower | replace('\"_', '') }}-{{ ansible_architecture }}.yml" - "pre-{{ ansible_os_family|lower | replace('\"_', '') }}.yml" skip: true - name: Install mariadb package: name: "{{ package_item }}" state: "present" disablerepo: "{{ (online_status != 'online') | ternary('*', omit) }}" enablerepo: "{{ (online_status != 'online') | ternary('yunion-*', omit) }}" become: true with_items: - "{{ packages }}" loop_control: loop_var: package_item - name: Get pip version shell: | /usr/bin/python3 -m pip --version | awk '{print $2}' register: pip_version # the --break-system-packages is introduced since pip 23. # this block has been properly tested on all supported platforms as in https://www.cloudpods.org/docs/getting-started/onpremise/quickstart-virt - name: Pips for mysql/mariadb online pip: name: "{{ pip_item }}" extra_args: "{{ pip_version.stdout is version('23', '>=') | ternary('--break-system-packages', omit) }}" vars: ansible_python_interpreter: /usr/bin/python3 when: - online_status == "online" become: true loop: "{{ pips }}" loop_control: loop_var: pip_item - name: pips for mysql/mariadb offline pip: name: PyMySQL extra_args: "--no-index --find-links=file://{{ offline_data_path }}/pips" become: true vars: ansible_python_interpreter: /usr/bin/python3 when: - online_status == "offline" - offline_data_path is defined - offline_data_path | length > 0 - name: Copy my.cnf copy: src: my.cnf dest: /etc/my.cnf backup: yes become: true - name: create Mariadb Conf Path For Debian file: path: /etc/my.cnf.d state: directory become: true when: ansible_distribution == "Debian" - name: make conf dir file: name: /etc/my.cnf.d state: directory - name: initialize mariadb database shell: mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql become: true when: - manual_db_init | default(false) == true - name: enable and start mariadb systemd: name: mariadb enabled: yes state: started become: true - name: Change root password mysql_user: login_unix_socket: "{{ login_unix_socket }}" login_user: "{{ db_user }}" login_port: "{{ db_port | default(3306) }}" login_password: "{{ db_password }}" password: "{{ db_password }}" name: "{{ db_user }}" priv: "*.*:ALL,GRANT" host: "{{ item }}" check_implicit_admin: true become: true vars: ansible_python_interpreter: /usr/bin/python3 loop: - "localhost" - "{{ db_host }}" - "%" - "::1" - "127.0.0.1" - name: gather os specific Tasks for post installation include_tasks: "{{ item }}" with_first_found: - files: - "{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.{{ ansible_architecture }}.yml" - "{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml" - "{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_release|lower }}-{{ ansible_architecture }}.yml" - "{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_release|lower }}.yml" - "{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml" - "{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}-{{ ansible_architecture }}.yml" - "{{ ansible_distribution|lower | replace(' ', '_') | replace('\"_', '') }}.yml" - "{{ ansible_os_family|lower | replace('\"_', '') }}-{{ ansible_architecture }}.yml" - "{{ ansible_os_family|lower | replace('\"_', '') }}.yml" - defaults.yml skip: true