split msca data volume into role
[awsible] / roles / common / tasks / main.yml
1 ---
2 - name: Uninstall outdated python packages
3 with_items:
4 - aws-cli
5 - python27-botocore
6 - python27-boto
7 yum:
8 package: "{{ item }}"
9 state: absent
10
11 - name: Install new python packages
12 with_items:
13 - awscli
14 - boto
15 - boto3
16 pip:
17 name: "{{ item }}"
18 state: present
19
20 - name: Common packages
21 with_items:
22 - cowsay
23 - figlet
24 - ipsec-tools
25 - jq
26 - krb5-workstation
27 - pax
28 - rpcbind
29 - symlinks
30 - tcpdump
31 - strace
32 yum:
33 name: "{{ item }}"
34 state: latest
35
36 - name: Facts need a home.
37 file:
38 state: directory
39 path: /etc/ansible/facts.d
40 mode: "0755"
41 owner: root
42 group: root
43
44 - name: Install any facts.
45 with_items: "{{ fact_scripts|default([]) }}"
46 copy:
47 dest: /etc/ansible/facts.d/{{ item }}.fact
48 src: "{{ item }}.fact"
49 mode: "0755"
50 owner: root
51 group: root
52 register: new_facts
53
54 - name: Refresh facts
55 when: new_facts|changed
56 setup:
57
58 - name: Gather EC2 info
59 ec2_facts:
60
61 - name: Gather own tags
62 ec2_tag:
63 state: list
64 region: "{{ ansible_ec2_placement_region }}"
65 resource: "{{ ansible_ec2_instance_id }}"
66 register: my_tags
67
68 - name: Name instance from ID and ASG module
69 when: my_tags['tags']['aws:autoscaling:groupName'] is defined
70 ec2_tag:
71 state: present
72 region: "{{ ansible_ec2_placement_region }}"
73 resource: "{{ ansible_ec2_instance_id }}"
74 tags:
75 Name: "{{ my_tags['tags']['module']|default('(no module)') }}_{{ ansible_ec2_instance_id }}"
76
77 - name: MOTD Branding
78 copy:
79 dest: /etc/update-motd.d/31-branding
80 src: 31-branding
81 mode: "0755"
82 owner: root
83 group: root
84 register: motd
85 - name: update MOTD
86 when: motd|changed
87 command: /usr/sbin/update-motd
88
89 - name: profile stuff
90 template:
91 dest: /etc/profile.d/awsible.sh
92 src: awsible.sh.j2
93 mode: "0644"
94 owner: root
95 group: root
96
97 - name: fancy prompt
98 copy:
99 dest: /home/ec2-user/.bash_prompt
100 src: bash_prompt.sh
101 mode: "0644"
102 owner: ec2-user
103 group: ec2-user
104
105 - name: use fancy prompt
106 lineinfile:
107 dest: /home/ec2-user/.bash_profile
108 insertafter: EOF
109 line: "[[ -f ~/.bash_prompt ]] && . ~/.bash_prompt"
110
111 - name: Create AWS config
112 file:
113 state: directory
114 path: /home/ec2-user/.aws
115 mode: "0775"
116 owner: ec2-user
117 group: ec2-user
118
119 - name: awscli config
120 template:
121 dest: /home/ec2-user/.aws/config
122 src: aws.config.j2
123 mode: "0664"
124 owner: ec2-user
125 group: ec2-user