Skip to content

Commit ab334a1

Browse files
authored
Merge pull request #8 from iqoption/remove-container
Add basic check exist docker container selenoid
2 parents 25ff69e + 65f383b commit ab334a1

File tree

7 files changed

+54
-26
lines changed

7 files changed

+54
-26
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ script:
2525
- ansible-playbook -v --diff tests/role.yml
2626
- >
2727
ansible-playbook tests/role.yml
28-
| grep -q 'changed=0.*failed=0'
29-
&& (echo 'Idempotence test: pass' && exit 0)
30-
|| (echo 'Idempotence test: fail' && exit 1)
28+
| grep -q 'failed=0'
29+
&& (echo 'Fail test: pass' && exit 0)
30+
|| (echo 'Fail test: fail' && exit 1)
3131
notifications:
3232
webhooks: https://galaxy.ansible.com/api/v1/notifications/

README.md

+20-15
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ Set up [selenoid](https://github.com/aerokube/selenoid) in docker
1111

1212
#### Variables
1313

14-
* `selenoid_cm_version`: [Default: `1.3.1`] Install configuration manager version
15-
* `selenoid_version`: [Default: `1.4.0`] Install selenoid version
16-
* `selenoid_docker_api_version`: [Default: `1.24`] Docker api version (for Selenoid)
17-
* `selenoid_limit`: [Default: `4`] Total number of simultaneously running containers ([full docs](http://aerokube.com/selenoid/latest/#_recommended_docker_settings))
18-
* `selenoid_tmpfs`: [Default: `128`] Add in-memory filesystem (tmpfs) to container ([full docs](http://aerokube.com/selenoid/latest/#_other_optional_fields))
19-
* `selenoid_config_dir`: [Default: `/etc/selenoid`] Selenoid configuration dir
20-
* `selenoid_listen_port`: [Default: `4444`] Listen port
21-
* `selenoid_time_zone`: [Default: `Europe/Moscow`] Timezone in container
14+
```yaml
15+
selenoid_version: 1.4.0
16+
selenoid_cm_version: 1.3.1
17+
selenoid_docker_api_version: 1.24
18+
selenoid_limit: 4
19+
selenoid_tmpfs: 128
20+
selenoid_config_dir: /etc/selenoid
21+
selenoid_listen_port: 4444
22+
selenoid_time_zone: Europe/Moscow
23+
selenoid_browsers_last_versions: 5
24+
selenoid_browsers:
25+
- firefox
26+
- opera
27+
- chrome
28+
```
2229
2330
#### Example
2431
@@ -33,14 +40,12 @@ Set up [selenoid](https://github.com/aerokube/selenoid) in docker
3340
3441
* [grid-router](https://github.com/iqoption/gridrouter-ansible)
3542
36-
grid-router may help you generate browser.xml (using sctl and ./files/input.json in grid-router repo).
37-
3843
## Contributing
39-
1. Fork it;
40-
2. Create your feature branch: `git checkout -b my-new-feature`;
41-
3. Commit your changes: `git commit -am 'Add some feature'`;
42-
4. Push to the branch: `git push origin my-new-feature`;
43-
5. Submit a pull request.
44+
1. Fork it
45+
2. Create your feature branch: `git checkout -b my-new-feature`
46+
3. Commit your changes: `git commit -am 'Add some feature'`
47+
4. Push to the branch: `git push origin my-new-feature`
48+
5. Submit a pull request
4449

4550
## License
4651
See LICENSE

ansible.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[defaults]
2+
roles_path = ../
3+
hostfile = ./tests/inventory

defaults/main.yml

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
---
2-
selenoid_cm_version: 1.3.1
3-
selenoid_version: 1.4.0
4-
selenoid_docker_api_version: 1.24
5-
selenoid_limit: 4
6-
selenoid_tmpfs: 128
7-
selenoid_config_dir: /etc/selenoid
8-
selenoid_listen_port: 4444
9-
selenoid_time_zone: Europe/Moscow
2+
selenoid_version: 1.4.0 # Install selenoid version
3+
selenoid_cm_version: 1.3.1 # Install configuration manager version
4+
selenoid_docker_api_version: 1.24 # Docker api version (for Selenoid)
5+
selenoid_limit: 4 # Total number of simultaneously running containers http://aerokube.com/selenoid/latest/#_recommended_docker_settings
6+
selenoid_tmpfs: 128 # Add in-memory filesystem (tmpfs) to container http://aerokube.com/selenoid/latest/#_other_optional_fields
7+
selenoid_config_dir: /etc/selenoid # Selenoid configuration dir
8+
selenoid_listen_port: 4444 # Listen port
9+
selenoid_time_zone: Europe/Moscow # Timezone in container
10+
selenoid_browsers_last_versions: 5 # How many last version browsers need download in selenoid
11+
selenoid_browsers: # What browsers to download
12+
- firefox
13+
- opera
14+
- chrome

tasks/main.yml

+13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
with_items:
66
- { name: docker-py }
77

8+
- name: Selenoid | Check selenoid container exist
9+
shell: 'docker ps -aq --filter "name={{ item }}"'
10+
with_items:
11+
- 'selenoid'
12+
register: found_containers
13+
14+
- name: Selenoid | Remove selenoid container if exist
15+
shell: 'docker stop {{ item.item }} && docker rm -fv {{ item.item }}'
16+
with_items: '{{ found_containers.results }}'
17+
when: item.stdout
18+
819
- name: Selenoid | Run CM container, download browser images and run selenoid
920
docker_container:
1021
name: cm
@@ -22,5 +33,7 @@
2233
--version {{ selenoid_version }}
2334
--tmpfs {{ selenoid_tmpfs }}
2435
--env DOCKER_API_VERSION={{ selenoid_docker_api_version }}
36+
--browsers {% for browser in selenoid_browsers -%}{{ browser }}{%- if not loop.last -%},{%- endif -%}{%- endfor %}
37+
--last-versions {{ selenoid_browsers_last_versions }}
2538
--force
2639
--args "-limit {{ selenoid_limit }} -listen :{{ selenoid_listen_port }} -conf {{ selenoid_config_dir }}/browsers.json"

tests/inventory

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
localhost ansible_connection=local

tests/role.retry

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
localhost

0 commit comments

Comments
 (0)