- name: Hello Ansible hosts: unglueit vars: user: "{{ ansible_ssh_user }}" sudo: yes pre_tasks: - name: check apt last update stat: path=/var/cache/apt register: apt_cache_stat - name: update apt if needed apt: update_cache=yes when: ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > 60*60*12 tasks: - name: Hello server shell: date > now.txt # sudo add-apt-repository ppa:fkrull/deadsnakes-python2.7 - name: add-apt-repository ppa:fkrull/deadsnakes-python2.7 apt_repository: repo='ppa:fkrull/deadsnakes-python2.7' state=present update_cache=true - name: do apt-get update --fix-missing command: apt-get update --fix-missing # sudo apt-get install python2.7 - name: installing python 2.7 apt: pkg={{ item }} update_cache=yes state=latest with_items: - python2.7 tags: install