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