2.2.1. Deploy new Web Application

You will create a playbook to deploy new application to previously provisioned webservers.

  1. Create a playbook blue.yaml.

    • Type nano playbooks/blue.yaml
    • Type the following into the playbooks/blue.yaml file.
    ---
    
    - name: Deploy blue www servers
      hosts: appservers
      vars:
        valid_certs: no
    
      tasks:
        - name: Upload blue changes to server17
          copy:
            src: ../files/HackazonBlue.png
            dest: /var/www/hackazon1/web/images/Hackazon.png
          tags: 17blue
    
        - name: Upload blue changes to server20
          copy:
            src: ../files/HackazonBlue.png
            dest: /var/www/hackazon/web/images/Hackazon.png
          tags: 20blue
    
  2. Run this playbook.

    • Type ansible-playbook playbooks/blue.yaml

    If successful, you should see similar results

    ../../_images/image030.png
  3. Create a playbook green.yaml.

    • Type nano playbooks/green.yaml
    • Type the following into the playbooks/green.yaml file.
    ---
    
    - name: Deploy green www servers
      hosts: appservers
      vars:
        valid_certs: no
    
      tasks:
        - name: Upload green changes to server17
          copy:
            src: ../files/HackazonGreen.png
            dest: /var/www/hackazon1/web/images/Hackazon.png
          tags: 17green
    
        - name: Upload green changes to server20
          copy:
            src: ../files/HackazonGreen.png
            dest: /var/www/hackazon/web/images/Hackazon.png
          tags: 20green
    
  4. Run this playbook.

    • Type ansible-playbook playbooks/green.yaml

    If successful, you should see similar results

    ../../_images/image031.png