summaryrefslogtreecommitdiffstats
path: root/installer/roles/image_build/tasks/main.yml
blob: e0b8bd3fe12d4a84a33ed5e357bc2e3f55bceb69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
---
- name: Set global version if not provided
  set_fact:
    awx_version: "{{ lookup('file', playbook_dir + '/../VERSION') }}"
  when: awx_version is not defined

- name: Verify awx-logos directory exists for official install
  stat:
    path: "../../awx-logos"
  delegate_to: localhost
  register: logosdir
  failed_when: logosdir.stat.isdir is not defined or not logosdir.stat.isdir
  when: awx_official|default(false)|bool

- name: Copy logos for inclusion in sdist
  copy:
    src: "../../awx-logos/awx/ui/client/assets"
    dest: "../awx/ui/client/"
  delegate_to: localhost
  when: awx_official|default(false)|bool

- name: Set sdist file name
  set_fact:
    awx_sdist_file: "awx-{{ awx_version }}.tar.gz"

- name: AWX Distribution
  debug:
    msg: "{{ awx_sdist_file }}"

- name: Stat distribution file
  stat:
    path: "../dist/{{ awx_sdist_file }}"
  delegate_to: localhost
  register: sdist

- name: Clean distribution
  shell: make clean
  args:
    chdir: ..
  ignore_errors: true
  when: not sdist.stat.exists
  delegate_to: localhost

- name: Build sdist builder image
  docker_image:
    build:
      path: "{{ role_path }}/files"
      dockerfile: Dockerfile.sdist
      pull: false
      args:
        http_proxy: "{{ http_proxy | default('') }}"
        https_proxy: "{{ https_proxy | default('') }}"
        no_proxy: "{{ no_proxy | default('') }}"
    name: awx_sdist_builder
    tag: "{{ awx_version }}"
    source: 'build'
    force_source: true
  delegate_to: localhost
  when: use_container_for_build|default(true)|bool

- name: Build AWX distribution using container
  docker_container:
    env:
      http_proxy: "{{ http_proxy | default('') }}"
      https_proxy: "{{ https_proxy | default('') }}"
      no_proxy: "{{ no_proxy | default('') }}"
    image: "awx_sdist_builder:{{ awx_version }}"
    name: awx_sdist_builder
    state: started
    detach: false
    volumes:
      - ../:/awx:Z
  delegate_to: localhost
  when: use_container_for_build|default(true)|bool

- name: Build AWX distribution locally
  shell: make sdist
  args:
    chdir: ..
  delegate_to: localhost
  when: not use_container_for_build|default(true)|bool

- name: Set docker build base path
  set_fact:
    docker_base_path: "{{ awx_local_base_config_path|default('/tmp') }}/docker-image"

- name: Set awx image name
  set_fact:
    awx_image: "{{ awx_image|default('awx') }}"

- name: Ensure directory exists
  file:
    path: "{{ docker_base_path }}"
    state: directory
  delegate_to: localhost

- name: Stage sdist
  copy:
    src: "../dist/{{ awx_sdist_file }}"
    dest: "{{ docker_base_path }}/{{ awx_sdist_file }}"
  delegate_to: localhost

- name: Template web Dockerfile
  template:
    src: Dockerfile.j2
    dest: "{{ docker_base_path }}/Dockerfile"
  delegate_to: localhost

- name: Stage launch_awx
  copy:
    src: launch_awx.sh
    dest: "{{ docker_base_path }}/launch_awx.sh"
    mode: '0700'
  delegate_to: localhost

- name: Stage launch_awx_task
  template:
    src: launch_awx_task.sh.j2
    dest: "{{ docker_base_path }}/launch_awx_task.sh"
    mode: '0700'
  delegate_to: localhost

- name: Stage rsyslog.conf
  copy:
    src: rsyslog.conf
    dest: "{{ docker_base_path }}/rsyslog.conf"
    mode: '0660'
  delegate_to: localhost

- name: Stage supervisor.conf
  copy:
    src: supervisor.conf
    dest: "{{ docker_base_path }}/supervisor.conf"
  delegate_to: localhost

- name: Stage supervisor_task.conf
  copy:
    src: supervisor_task.conf
    dest: "{{ docker_base_path }}/supervisor_task.conf"
  delegate_to: localhost

- name: Stage settings.py
  copy:
    src: settings.py
    dest: "{{ docker_base_path }}/settings.py"
  delegate_to: localhost

- name: Stage requirements
  copy:
    src: ../requirements/
    dest: "{{ docker_base_path }}/requirements"
  delegate_to: localhost

- name: Stage config watcher
  copy:
    src: ../tools/scripts/config-watcher
    dest: "{{ docker_base_path }}/config-watcher"
    mode: 0755
  delegate_to: localhost

- name: Stage Makefile
  copy:
    src: ../Makefile
    dest: "{{ docker_base_path }}/Makefile"
  delegate_to: localhost

- name: Build base awx image
  docker_image:
    build:
      path: "{{ docker_base_path }}"
      dockerfile: Dockerfile
      pull: false
      args:
        http_proxy: "{{ http_proxy | default('') }}"
        https_proxy: "{{ https_proxy | default('') }}"
        no_proxy: "{{ no_proxy | default('') }}"
    name: "{{ awx_image }}"
    tag: "{{ awx_version }}"
    source: 'build'
    force_source: true
  delegate_to: localhost

- name: Tag awx images as latest
  command: "docker tag {{ item }}:{{ awx_version }} {{ item }}:latest"
  delegate_to: localhost
  with_items:
    - "{{ awx_image }}"

- name: Clean docker base directory
  file:
    path: "{{ docker_base_path }}"
    state: absent
  when: cleanup_docker_base|default(True)|bool
  delegate_to: localhost