Ansible 配置 wordpress(mysql + wordpress + php + web)
需要使用 ansible配置 mysql、php、wordpress 和 web
一、Ansible 配置 LAMP:
1、附件:
(1)apache2 网页配置文件:
2、剧本:
没写完,mysql的写完了
---- name: Web and PHP hosts: Server3,Server4 gather_facts: false tasks: - name: Install basic software apt: name: - apache2 - php8.2-fpm - wordpress update_cache: false - name: Configure Web SSL copy: src: /data/server.crt dest: /etc/ssl - name: Configure Web SSL copy: src: /data/server.key dest: /etc/ssl - name: Configure Web SSL shell: | /usr/sbin/a2enmod ssl /usr/sbin/a2enmod php8.2 /usr/sbin/a2enconf php8.2-fpm changed_when: false- name: Mariadb-Server hosts: Server5 gather_facts: false tasks: - name: Install Mysql apt: name: - mariadb-server - python3-mysqldb update_cache: false - name: Set Mysql allow remote host access lineinfile: path: /etc/mysql/mariadb.conf.d/50-server.cnf search_string: "bind-address" line: "bind-address = *" notify: restart - name: Create mysql data mysql_db: name: wordpress state: present - name: Create mysql user mysql_user: name: wordpress password: Skills39 priv: 'wordpress.*:ALL' host: '%' state: present handlers: - name: restart systemd: name: mysql state: restarted