• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Ansible Ubuntu 16.04 1 Click Install WordPress, Nginx Playbook Tutorial

By Abhishek Ghosh June 11, 2016 8:08 am Updated on July 18, 2016

Ansible Ubuntu 16.04 1 Click Install WordPress, Nginx Playbook Tutorial

Advertisement

This guide, Ansible 1 Click Install WordPress, Nginx Playbook Tutorial For Ubuntu 16.04 is a good example of automation. Following This Step By Step Guide, You Will Be Able to Create Own Ansible 1 Click Install WordPress Nginx Playbook For Ubuntu 16.04. Which is practical now to upgrade from Ubuntu 14.04 for many of your servers.. The intention of this guide to teach how to convert normal step by step guide to Install WordPress, Nginx on Ubuntu 16.04 to an Ansible Playbook. It will take hardly 1 hour to create this stuff even if you know nothing about Ansible.

Unlike the bash scripts, the developers do not need much time to modify an existing Ansible Playbook to change from Ubuntu 14.04 to Ubuntu 16.04. Basically, the Third Party bulky software like Easy Engine is outdated approach and risky as they has less number of contributers when compared to our so-called typical DevOps tools or tools for automation on the cloud. We have normal step by step guide to Install WordPress, Nginx on Ubuntu 16.04 and the same guide as one click bash script to install WordPress, Nginx, Percona MySQL on Ubuntu 16.04. However, Ansible is Designed for Automation & Making the Coding Part Easier. Any Level of User Can Use Ansible 1 Click Install WordPress Nginx on Ubuntu 16.04. OpenStack Hot and Heat are more advanced and highly customizable for managing own or HP Cloud, Rackspace or other Third Party installed OpenStack environment.

Ansible Ubuntu 16.04 1 Click Install WordPress, Nginx Playbook Tutorial

 

Learning Resources For Using Ansible 1 Click Install WordPress, Nginx Playbook For Ubuntu 16.04

 

For the sake of learning Ansible, unless you already used Ansible before, reading guides like Getting Started With Ansible, Tutorial on Ansible Playbooks is mandatory need. For this tutorial, we will one server configuration, which is most easy. We have some existing good Playbooks to start with :

Advertisement

---

repo for Ubuntu 14.04
Vim
1
2
3
https://github.com/ansible/ansible-examples/tree/master/wordpress-nginx
https://github.com/lamosty/wordpress-ansible
https://roots.io/trellis/

We can easily install Ansible with these commands :

repo for Ubuntu 14.04
Vim
1
2
3
4
sudo easy_install pip
sudo pip install ansible
sudo pip install --upgrade ansible
ansible --version

Current version of Ansible is 2.1 and ansible-2.1.0.0.tar.gz is 1.9MB in size.

or with,

Vim
1
apt install ansible

 

Steps For Cteating Ansible 1 Click Install WordPress, Nginx Playbook for Ubuntu 16.04.04

 

Because of the changes in Ubuntu 16.04 compared to Ubuntu 14.04 and our preferance towards Percona MySQL, we need to start from scratch. In other words, we will create Ansible version of our step by step guide to Install WordPress, Nginx on Ubuntu 16.04. As you are I are different, you may need to create your own, instead of blindly running ours!

location = ~
Vim
1
2
3
4
cd ~
mkdir wordpress-ansible && cd wordpress-ansible
touch playbook.yml && touch hosts
mkdir roles && cd roles

Now, we will proceed to bootstrap our roles with the Ansible tool called ansible-galaxy. For each role, we will run ansible-galaxy init. It is kind of “automatic system” to create the structure :

location = ~/wordpress-ansible/roles
Vim
1
2
3
4
ansible-galaxy init server
ansible-galaxy init php
ansible-galaxy init mysql
ansible-galaxy init wordpress

You’ll get response like –

Vim
1
- server was created successfully

Now, we will edit the hosts file with nano ~/wordpress-ansible/hosts or vi ~/wordpress-ansible/hosts command and add the working block :

hosts
Vim
1
2
[wordpress]
127.0.0.1

127.0.0.1 is example of your server’s IP. If you work from server, 127.0.0.1 obviously work. Now we will edit playbook.yml with nano ~/wordpress-ansible/playbook.yml or vi ~/wordpress-ansible/playbook.yml command and make it looking like this :

location = ~/wordpress-ansible/playbook.yml
Vim
1
2
3
4
5
6
7
- hosts: wordpress
 
  roles:
    - server
    - php
    - mysql
    - wordpress

Again we will go back to ~/wordpress-ansible/ directory to run and check whether it is fine :

location = ~/wordpress-ansible/
Vim
1
ansible-playbook playbook.yml -i hosts -u root -K

We have not installed anything with the above command. Now we will create tasks. We will create the needed file with vi ~/wordpress-ansible/roles/server/tasks/main.yml or nano ~/wordpress-ansible/roles/server/tasks/main.yml command and add :

location = ~/wordpress-ansible/roles/server/tasks/main.yml
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
# tasks file for server
 
- name: Update apt cache
  apt: update_cache=yes cache_valid_time=3600
  sudo: yes
 
- name: Install required software
  apt: name={{ item }} state=present
  sudo: yes
  with_items:
    - nginx-extras
    - memcached
    - libcurl3
    - libmcrypt4
    - libxmlrpc-epi0
    - libmemcached11
    - libmhash2
    - php7.0-common
    - mcrypt
    - libmcrypt-dev
    - psmisc
 
- name: Add Percona apt signing key
  sudo: yes
  apt_key: keyserver=keys.gnupg.net id=1C4CBDCDCD2EFD2A state=present
 
- name: Add Percona repository
  sudo: yes
  apt_repository: repo='deb http://repo.percona.com/apt xenial main' state=present
 
- name: Add Percona source repository
  sudo: yes
  apt_repository: repo='deb-src http://repo.percona.com/apt xenial main' state=present
 
- name: Update apt
  raw: apt-get update
 
- name: Apt debconf create
  copy: src=apt-debconf-mysql.conf dest=/root/.apt-debconf-mysql.conf owner=root mode=400
 
- name: Apt debconf selecttions
  action: command debconf-set-selections /root/.apt-debconf-mysql.conf
 
- name: Install python packages
  sudo: yes
  apt: pkg={{ item }} state=present
  with_items:
    - vim
    - python-pycurl
    - python-mysqldb
    - python-mysqldb
 
- name: Install Percona packages
  sudo: yes
  apt: pkg={{ item }} state=present update_cache=yes
  with_items:
    - percona-server-5.7
    - percona-server-client-5.7
    - percona-server-server-5.7
  environment:
    DEBIAN_FRONTEND: noninteractive
 
- name: Update mysql root password for all root accounts
  sudo: yes
  mysql_user: name=root host={{ item }} password={{ mysql_root_password }}
  with_items:
    - "{{ ansible_hostname }}"
    - 127.0.0.1
    - ::1
    - localhost
 
- name: Delete nginx configuration
  raw : rm /etc/nginx/conf.d/default
 
- name: Copy nginx configuration for wordpress
  template: src=default.conf dest=/etc/nginx/conf.d/default
  notify: restart nginx
 
- name: Copy mysql configuration for wordpress
  template: src=my.cnf dest=/etc/mysql/my.cnf
  notify: restart nginx

CD to ~/wordpress-ansible/roles/server/templates and add the my.cnf and default from our step by step guide to Install WordPress, Nginx on Ubuntu 16.04.

Now, in PHP’s role, we will create the needed file with vi ~/wordpress-ansible/roles/php/tasks/main.yml or nano ~/wordpress-ansible/roles/php/tasks/main.yml command and add :

location = ~/wordpress-ansible/roles/server/tasks/main.yml
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
# tasks file for php
 
- name: Install php extensions
  apt: name={{ item }} state=present
  sudo: yes
  with_items:
    - php7.0-cli
    - php7.0-curl
    - php7.0-fpm
    - php7.0-gd
    - php7.0-intl
    - php7.0-json
    - php7.0-mbstring
    - php7.0-mcrypt
    - php7.0-mysql
    - php7.0-opcache
    - php7.0-readline
    - php7.0-xml
    - php7.0-xmlrpc
    - php-pear
    - php-mbstring
    - php-mcrypt
    - php-xml
    - php-intl
    - php-common
    - libssh2-php

Now, we will create the needed file for MySQL with the command nano ~/wordpress-ansible/roles/mysql/defaults/main.yml command and add :

location = ~/wordpress-ansible/roles/mysql/defaults/main.yml
Vim
1
2
3
4
5
6
---
# defaults file for mysql
 
wp_mysql_db: wordpress
wp_mysql_user: wordpress
wp_mysql_password: wp_db_password

In the next step, we will create the needed file for MySQL with the command nano ~/wordpress-ansible/roles/mysql/tasks/main.yml command and add :

location = ~/wordpress-ansible/roles/mysql/tasks/main.yml
Vim
1
2
3
4
5
6
7
8
9
10
11
---
# tasks file for mysql
 
- name: Create mysql database
  mysql_db: name={{ wp_mysql_db }} state=present
 
- name: Create mysql user
  mysql_user:
    name={{ wp_mysql_user }}
    password={{ wp_mysql_password }}
    priv=*.*:ALL

For WordPress, we will edit with the command nano ~/wordpress-ansible/roles/wordpress/tasks/main.yml and add :

location = ~/wordpress-ansible/roles/wordpress/tasks/main.yml
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
# tasks file for wordpress
 
- name: Download WordPress
    get_url: url=https://wordpress.org/latest.tar.gz
    sha256sum="{{ wp_sha256sum }}
    dest=/tmp/wordpress.tar.gz
    validate_certs=no
 
- name: Extract WordPress  unarchive: src=/tmp/wordpress.tar.gz dest=/usr/share/nginx/html copy=no
  sudo: yes
 
- name: Copy sample config file
  command: mv /usr/share/nginx/html/wordpress/wp-config-sample.php /usr/share/nginx/html/wordpress/wp-config.php creates=/usr/share/nginx/html/wordpress/wp-config.php
  sudo: yes
 
- name: Update WordPress config file
  lineinfile:
    dest=/usr/share/nginx/html/wordpress/wp-config.php
    regexp="{{ item.regexp }}"
    line="{{ item.line }}"
  with_items:
    - {'regexp': "define\\('DB_NAME', '(.)+'\\);", 'line': "define('DB_NAME', '{{wp_mysql_db}}');"}        
    - {'regexp': "define\\('DB_USER', '(.)+'\\);", 'line': "define('DB_USER', '{{wp_mysql_user}}');"}        
    - {'regexp': "define\\('DB_PASSWORD', '(.)+'\\);", 'line': "define('DB_PASSWORD', '{{wp_mysql_password}}');"}
  sudo: yes
 
- name: Move WordPress to root
  raw : mv /usr/share/nginx/html/wordpress/* /usr/share/nginx/html
  sudo: yes
 
- name: Fix CGI PATH
  raw : echo "cgi.fix_pathinfo=0" >> /etc/php5/cgi/php.ini
  sudo: yes

Again we will go back to ~/wordpress-ansible/ directory to run for final WordPress installation :

clocation = ~/wordpress-ansible/
Vim
1
ansible-playbook playbook.yml -i hosts -u root -K

Now you can create millions of WordPress server with your Playbook. You learned how to copy template, how to remove files, how add repository in Ansible.

Tagged With https://thecustomizewindows com/2016/06/ansible-ubuntu-16-04-1-click-install-wordpress-nginx-playbook-tutorial/ , ansible wordpress nginx php7 , ansible nginx wordpress , paperuri:(aa248f36cfeaae8856dd518c9f5fb100) , how to Install MySQL for ununtu 16 04 in ansible playbook , ansible wordpress ubuntu 16 , ansible wordpress ngnix , ansible playbook for nginx installation , ansible playbook for java installation in ubuntu 16 , ansible php7 ubuntu
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Ansible Ubuntu 16.04 1 Click Install WordPress, Nginx Playbook Tutorial

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • How to Install WordPress : Ubuntu 16.04, Nginx, PHP7-FPM

    Here is Step by Step Guide on How to Install WordPress on Ubuntu 16.04, Nginx, PHP7-FPM, memcached & Percona MySQL 5.7 on Cloud Server or VPS.

  • Get Started With Ansible Playbooks

    First, We Got Started By Installing Ansible. In this Guide We Will Get Started With Ansible Playbooks With Very Easy to Understand Examples.

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy