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