--- - name: Uninstall outdated python packages with_items: - aws-cli - python27-botocore - python27-boto yum: package: "{{ item }}" state: absent - name: Install new python packages with_items: - awscli - boto - boto3 pip: name: "{{ item }}" state: latest - name: Common packages with_items: - cowsay - figlet - ipsec-tools - jq - krb5-workstation - pax - rpcbind - symlinks - tcpdump - strace yum: name: "{{ item }}" state: latest - name: Facts need a home. file: state: directory path: /etc/ansible/facts.d mode: "0755" owner: root group: root - name: Install any facts. with_items: "{{ fact_scripts|default([]) }}" copy: dest: /etc/ansible/facts.d/{{ item }}.fact src: "{{ item }}.fact" mode: "0755" owner: root group: root register: new_facts - name: Refresh facts when: new_facts|changed setup: - name: Gather EC2 info ec2_facts: - name: Gather own tags ec2_tag: state: list region: "{{ ansible_ec2_placement_region }}" resource: "{{ ansible_ec2_instance_id }}" register: my_tags - name: Name instance from ID and ASG module when: my_tags['tags']['aws:autoscaling:groupName'] is defined ec2_tag: state: present region: "{{ ansible_ec2_placement_region }}" resource: "{{ ansible_ec2_instance_id }}" tags: Name: "{{ my_tags['tags']['module']|default('(no module)') }}_{{ ansible_ec2_instance_id }}" - name: MOTD Branding copy: dest: /etc/update-motd.d/31-branding src: 31-branding mode: "0755" owner: root group: root register: motd - name: update MOTD when: motd|changed command: /usr/sbin/update-motd - name: profile stuff template: dest: /etc/profile.d/awsible.sh src: awsible.sh.j2 mode: "0644" owner: root group: root - name: fancy prompt copy: dest: /home/ec2-user/.bash_prompt src: bash_prompt.sh mode: "0644" owner: ec2-user group: ec2-user - name: use fancy prompt lineinfile: dest: /home/ec2-user/.bash_profile insertafter: EOF line: "[[ -f ~/.bash_prompt ]] && . ~/.bash_prompt" - name: Create AWS config file: state: directory path: /home/ec2-user/.aws mode: "0775" owner: ec2-user group: ec2-user - name: awscli config template: dest: /home/ec2-user/.aws/config src: aws.config.j2 mode: "0664" owner: ec2-user group: ec2-user