2
votes

I am trying to install Apache 2, PHP on Ubuntu machine using the ansible-playbook. I am getting the following error Error after executing playbook

fatal: [18.220.215.181]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (systemd) module: enable Supported parameters include: daemon_reexec, daemon_reload, enabled, force, masked, name, no_block, scope, state, user"}The ansible playbook is as follows--- - hosts: all become: yes tasks: - name: Chenking ping ping: - name: Update packages apt: name: apache2 update_cache: yes state: present - name: restart apache2 server service: name: apache2 enable: yes state: restarted - name: install php module apt: name: "{{ item }}" state: present with_items: - php - libapache2-mod-php5 - php-mcrypt - php-mysql - name: restart apache2 afetr restart service: name: apache2 enable: yes state: restarted

`

2
What version of Ubuntu and Ansible? and can you post the whole error message, as it's not clear on what task the error happens. - Augusto
Ubuntu version is 18 and ansible version is 2.8, For error message click on hyperlink "Error after executing playbook" in above question i have attached the error message in form of image - Armaan

2 Answers

3
votes

The right parameter is enabled (not enable) in your service tasks.

  - name: restart apache2 afetr restart
    service:
      name: apache2
      enabled: yes
      state: restarted
0
votes

Change "enabled" task containing service module.

- hosts: all
  become: yes
  tasks:
  - name: Chenking ping
    ping:
  - name: Update packages
    apt:
      name: apache2
      update_cache: yes
      state: present
  - name: restart apache2 server
    service:
      name: apache2
      enabled: yes
      state: restarted
  - name: install php module
    apt:
      name: "{{ item }}"
      state: present
    with_items:
     - php
     - libapache2-mod-php5
     - php-mcrypt
     - php-mysql

I think last task is not required.