linuxacademy / terransible

67 stars 256 forks source link

unable to install apache using Ansible-playbook #6

Closed hit-monchan closed 5 years ago

hit-monchan commented 5 years ago

I am a beginner in terraform and ansible. I am following the linuxacademy course to deploy a wordpress website using terraform and ansible in an aws enviroment.

Course reference : https://github.com/linuxacademy/terransible/tree/master/course_scripts

My setup: OS version : Ubuntu Server 16.04 ansible version : 2.4.2.0 python version 2.7.12

After went through alot of troubleshooting, I am able to run terraform apply successfully.

When i run ansible-playbook -i aws_hosts wordpress.yml, i encounter this error

TASK [Install Apache.] *******************************************************************************************************
failed: [111.22.22.22] (item=[u'httpd', u'php', u'php-mysql']) => {"changed": false, "item": ["httpd", "php", "php-mysql"], "msg": "No package matching 'httpd' found available, installed or updated", "rc": 126, "results": ["No package matching 'httpd' found available, installed or updated"]}

Here is my wordpress.yml config file

    ---
    - hosts: dev
      become: yes
      remote_user: ubuntu
      gather_facts: false
      tasks:
        - name: Check for Python
          raw: test -e /usr/bin/python2
          changed_when: false
          failed_when: false
          register: check_python
        - name: Install Python
          raw: apt -y update && apt install -y python-minimal
          when: check_python.rc != 0
        - set_fact:
            ansible_python_default_interpreter: "{{ ansible_python_interpreter }}"
            ansible_python_interpreter: "/usr/bin/python"
        - name: Install Apache.
          yum: name={{ item }} state=present
          with_items:
          - httpd
          - php
          - php-mysql
        - name: Download WordPress
          get_url: url=http://wordpress.org/wordpress-5.0.2.tar.gz dest=/var/www/html/wordpress.tar.gz force=yes
        - name: Extract WordPress
          command: "tar xzf /var/www/html/wordpress.tar.gz -C /var/www/html --strip-components 1"
        - name: Make my directory tree readable
          file:
            path: /var/www/html/
            mode: u=rwX,g=rX,o=rX
            recurse: yes
            owner: apache
            group: apache
        - name: Make sure Apache is started now and at boot.
          service: name=httpd state=started enabled=yes

Here is my main.tf attached main.tf.txt

Check python and yum is installed and tested running ok but not sure why the error message ? Please help if any kind soul able to knows what is the issue here. Appreciate it and thanks !