- name: setup group
  action: group name={{group_name}} state=present
- name: setup user
  action: user name={{user_name}} state=present group={{group_name}}
- name: set up packages
  action: apt pkg={{item}} state=latest update_cache=yes
  with_items: required_packages
- name: ensure directories
  action: file state=directory path={{item}} owner={{user_name}} group={{group_name}}
  with_items:
    - "{{deploy_root}}"
    - "{{deploy_root}}/conf.d"
- include: nginx.yml
- include: configuration.yml
- name: copy source
  copy: src=../src_pkg.tar.gz dest={{webapp_archive_location}}
  register: sources
  notify: reload nginx config
- include: install_sources.yml
  when: sources.changed or configuration.changed
- name: install systemd service
  action: template src=../templates/gunicorn.service.j2 dest=/lib/systemd/system/{{app_name}}-wsgi.service
  when: sources.changed or configuration.changed
  register: systemd_change
- name: reload systemd daemon
  action: shell systemctl daemon-reload
  when: systemd_change
- name: enable the services
  action: service name={{app_name}}-wsgi enabled=true state=restarted
  when: systemd_change
- name: try to get local page
  shell: curl http://localhost/

- name: setup group
  action: group name={{group_name}} state=present
- name: setup user
  action: user name={{user_name}} state=present group={{group_name}}
- name: set up packages
  action: apt pkg={{item}} state=latest update_cache=yes
  with_items: required_packages
- name: ensure directories
  action: file state=directory path={{item}} owner={{user_name}} group={{group_name}}
  with_items:
    - "{{deploy_root}}"
    - "{{deploy_root}}/conf.d"
- include: nginx.yml
- include: configuration.yml
- name: copy source
  copy: src=../src_pkg.tar.gz dest={{webapp_archive_location}}
  register: sources
  notify: reload nginx config
- include: install_sources.yml
  when: sources.changed or configuration.changed
- name: install systemd service
  action: template src=../templates/gunicorn.service.j2 dest=/lib/systemd/system/{{app_name}}-wsgi.service
  when: sources.changed or configuration.changed
  register: systemd_change
- name: reload systemd daemon
  action: shell systemctl daemon-reload
  when: systemd_change.changed
- name: enable the services
  action: service name={{app_name}}-wsgi enabled=true state=restarted
  when: systemd_change.changed
- name: try to get local page
  shell: curl http://localhost/

Fix webapp role in ansible
Fix webapp role in ansible
