Advertisement
raf8

playbokk-ukk

Oct 25th, 2024 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.58 KB | Source Code | 0 0
  1. - hosts: all
  2.   become: yes
  3.  
  4.   tasks:
  5.     - name: Update package repository
  6.       apt:
  7.         update_cache: yes
  8.  
  9. - hosts: wp
  10.   become: yes
  11.  
  12.   tasks:
  13.     - name: Install MySQL and PHP
  14.       apt:
  15.         name:
  16.          - mysql-server
  17.           - php
  18.           - php-mysql
  19.         state: present
  20.  
  21. - hosts: web
  22.   become: yes
  23.  
  24.   tasks:
  25.     - name: Install Apache, MariaDB, and PHP
  26.       apt:
  27.         name:
  28.          - apache2
  29.           - mariadb-server
  30.           - php
  31.           - php-mysqli
  32.           - php-mbstring
  33.         state: present
  34.  
  35. - hosts: all
  36.   become: yes
  37.  
  38.   tasks:
  39.     - name: Install Python MySQL dependencies
  40.       apt:
  41.         name: python3-pymysql
  42.         state: present
  43.  
  44. - hosts: wp
  45.   become: yes
  46.  
  47.   tasks:
  48.     - name: Create MySQL admin user
  49.       mysql_user:
  50.         name: word
  51.         password: word123
  52.         priv: "*.*:ALL,GRANT"
  53.         host: "%"
  54.         state: present
  55.         login_unix_socket: /var/run/mysqld/mysqld.sock
  56.  
  57.     - name: Create WordPress database
  58.       mysql_db:
  59.         name: db_wordpress
  60.         state: present
  61.         login_user: word
  62.         login_password: word123
  63.  
  64.     - name: Download WordPress
  65.       get_url:
  66.         url: https://wordpress.org/latest.tar.gz
  67.         dest: /tmp/wordpress.tar.gz
  68.  
  69.     - name: Extract WordPress
  70.       unarchive:
  71.         src: /tmp/wordpress.tar.gz
  72.         dest: /var/www/
  73.         remote_src: yes
  74.  
  75.     - name: Copy wp-config-sample.php to wp-config.php
  76.       command: cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
  77.       args:
  78.         creates: /var/www/wordpress/wp-config.php
  79.  
  80.     - name: Configure wp-config.php
  81.       lineinfile:
  82.         path: /var/www/wordpress/wp-config.php
  83.         regexp: "{{ item.regexp }}"
  84.         line: "{{ item.line }}"
  85.       loop:
  86.         - { regexp: "DB_NAME", line: "define('DB_NAME', 'db_wordpress');" }
  87.         - { regexp: "DB_USER", line: "define('DB_USER', 'word');" }
  88.         - { regexp: "DB_PASSWORD", line: "define('DB_PASSWORD', 'word123');" }
  89.         - { regexp: "DB_HOST", line: "define('DB_HOST', 'localhost');" }
  90.  
  91.     - name: Update Apache VirtualHost for WordPress
  92.       replace:
  93.         path: /etc/apache2/sites-available/000-default.conf
  94.         regexp: 'DocumentRoot /var/www/html'
  95.         replace: 'DocumentRoot /var/www/wordpress'
  96.  
  97. - hosts: web
  98.   become: yes
  99.  
  100.   tasks:
  101.     - name: Create MySQL admin user
  102.       mysql_user:
  103.         name: cyber
  104.         password: pass2023
  105.         priv: "*.*:ALL,GRANT"
  106.         host: "%"
  107.         state: present
  108.         login_unix_socket: /var/run/mysqld/mysqld.sock
  109.  
  110.     - name: Create Blog database
  111.       mysql_db:
  112.         name: cyber23
  113.         state: present
  114.         login_user: cyber
  115.         login_password: pass2023
  116.  
  117.     - name: Clone blog repository
  118.       git:
  119.         repo: https://github.com/rpipp/Patch-WebVuln-UKK.git
  120.         dest: /var/www/Patch-WebVuln-UKK
  121.  
  122.     - name: Import SQL file into database
  123.       mysql_db:
  124.         name: cyber23
  125.         state: import
  126.         target: /var/www/Patch-WebVuln-UKK/db.sql
  127.         login_user: cyber
  128.         login_password: pass2023
  129.  
  130.     - name: Update Apache VirtualHost for blog
  131.       replace:
  132.         path: /etc/apache2/sites-available/000-default.conf
  133.         regexp: 'DocumentRoot /var/www/html'
  134.         replace: 'DocumentRoot /var/www/Patch-WebVuln-UKK'
  135.  
  136. - hosts: all
  137.   become: yes
  138.  
  139.   tasks:
  140.     - name: Enable the new site configuration
  141.       command: a2ensite 000-default.conf
  142.  
  143.     - name: Restart Apache to apply changes
  144.       service:
  145.         name: apache2
  146.         state: restarted
  147.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement