-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4182d8d
commit 0589b5c
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[host1] | ||
host1 ansible_host=localhost ansible_connection=ssh ansible_ssh_port=2223 ansible_user=root ansible_password=veronika | ||
|
||
[targets] | ||
host1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- name: Play1 | ||
hosts: host1 | ||
tasks: | ||
- name: Pinge-Ponge | ||
ping: | ||
|
||
# - name: Bad task (will fail) | ||
# shell: "mv biba boba" | ||
|
||
- name: Creates very important directory | ||
file: | ||
path: /home/ubuntu/important_dir | ||
state: directory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Contributing | ||
For development purposes you have to be able to run Ansible. If you don't have Ansible host, inventory files and etc, or you don't want to run Ansible against your hosts in cotea development purposes, there is a guide below for you. | ||
|
||
1. Run Ansible host | ||
(our special container) | ||
|
||
```bash | ||
docker run --name ans_host --rm -d -p 2222:22 dbadalyan/ansible_host_for_cotea /path/to/your/public_key.pub | ||
``` | ||
Port 2222 is used here as a *ansible_ssh_port*. You can use the preferred one. | ||
|
||
2. Get required files | ||
|
||
If you have your own inventory or playbook files - you can use ones instead. | ||
|
||
Clone cotea repo: | ||
```bash | ||
git clone https://github.com/ispras/cotea | ||
``` | ||
|
||
You need an inventory file: | ||
```bash | ||
cp cotea/docs/contributing/contr_inv contr_inv | ||
``` | ||
*ansible_port* is 2222 in this file, set the preferred one if you changed it in *docker run* command. | ||
|
||
Playbook file: | ||
```bash | ||
cp cotea/docs/contributing/contr_pb.yaml contr_pb.yaml | ||
``` | ||
|
||
Python file with cotea imports and Ansible launch: | ||
```bash | ||
cp cotea/docs/contributing/cotea_ansible_run.py cotea_ansible_run.py | ||
``` | ||
|
||
3. Run Ansible using cotea | ||
|
||
```bash | ||
python3 cotea_ansible_run.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from cotea.runner import runner | ||
from cotea.arguments_maker import argument_maker | ||
from cotea.debug_utils import interactive_discotech | ||
|
||
|
||
pb_path = "contr_pb.yaml" | ||
inv = "contr_inv" | ||
|
||
arg_maker = argument_maker() | ||
|
||
arg_maker.add_arg("-i", inv) | ||
|
||
r = runner(pb_path, arg_maker) | ||
|
||
while r.has_next_play(): | ||
while r.has_next_task(): | ||
task_results = r.run_next_task() | ||
|
||
some_task_failed = False | ||
failed_task = None | ||
for task in task_results: | ||
if task.is_failed or task.is_unreachable: | ||
some_task_failed = True | ||
failed_task = task.task_ansible_object | ||
break | ||
|
||
if some_task_failed: | ||
interactive_discotech(failed_task, r) | ||
|
||
r.ignore_errors_of_next_task() | ||
|
||
r.finish_ansible() | ||
|
||
if r.was_error(): | ||
print("Ansible - failed:") | ||
print(r.get_error_msg()) | ||
else: | ||
print("Ansible - OK") |