--- - name: Install helpful development packages package: name={{ item }} state=present with_items: - gcc - git - libffi-devel - nmap-ncat - openssl-devel - postgresql-devel - python2-devel - python3-devel - python3-tox - python-virtualenvwrapper - redhat-rpm-config - vim-enhanced - name: Install a custom bashrc copy: src:bashrc dest: /home/{{ ansible_env.SUDO_USER }}/.bashrc mode: 0644 owner: "{{ ansible_env.SUDO_USER }}" group: "{{ ansible_env.SUDO_USER }}" - name: Install the message of the day copy: src=motd dest=/etc/motd - name: Create virtualenv become_user: "{{ ansible_env.SUDO_USER }}" shell: > source ~/.bashrc && mkvirtualenv --python=python3 -a ~/devel/ petshop args: creates: /home/{{ ansible_env.SUDO_USER }}/.virtualenvs/petshop - name: Install dev requirements into the virtualenv become_user: "{{ ansible_env.SUDO_USER }}" pip: requirements: "dev-requirements.txt" virtualenv: /home/{{ ansible_env.SUDO_USER }}/.virtualenvs/petshop/ virtualenv_python: python3 args: chdir: /home/{{ ansible_env.SUDO_USER }}/devel - name: Install app into the virtualenv become_user: "{{ ansible_env.SUDO_USER }}" pip: name: "file:///home/{{ ansible_env.SUDO_USER }}/devel" extra_args: "-e" virtualenv: /home/{{ ansible_env.SUDO_USER }}/.virtualenvs/petshop/ virtualenv_python: python3 - name: Create user systemd directory become_user: "{{ ansible_env.SUDO_USER }}" file: path: /home/{{ ansible_env.SUDO_USER }}/.config/systemd/user/ state: directory - name: Install the app systemd service file become_user: "{{ ansible_env.SUDO_USER }}" copy: src: anitya.service dest: /home/{{ ansible_env.SUDO_USER }}/.config/systemd/user/petshop.service - name: Reload the systemd daemon become_user: "{{ ansible_env.SUDO_USER }}" command: systemctl --user daemon-reload - name: Start the app become_user: "{{ ansible_env.SUDO_USER }}" command: systemctl --user restart petshop.service