X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=roles%2Fcommon%2Ftasks%2Fmain.yml;fp=roles%2Fcommon%2Ftasks%2Fmain.yml;h=02f3b0ad88681c70a0b3d853fa046b060d636a65;hb=164fb4ac7aebf84ca89433aeee8d16771fb8b7da;hp=0000000000000000000000000000000000000000;hpb=eff6951aff36874ec094e80849ee3095800b7e76;p=awsible diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml new file mode 100644 index 0000000..02f3b0a --- /dev/null +++ b/roles/common/tasks/main.yml @@ -0,0 +1,128 @@ +--- +- include: volumes.yml + +- name: Create local asset directory + when: ASSET_PATH is defined + file: + state: directory + path: {{ ASSET_PATH }} + mode: "0755" + owner: root + group: root + +- name: PIP prerequisites + with_items: + - boto + - boto3 + - httplib2 + - requests + pip: + name: "{{ item }}" + state: latest + +- name: Common packages + with_items: + - aws-cli + - 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(None) }}" + 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 }}" + +- 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 + copy: + dest: /etc/profile.d/awsible.sh + src: awsible.sh + 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