summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorsirkubax <muszynski@so1.net>2017-10-27 14:42:44 +0200
committersirkubax <muszynski@so1.net>2017-10-27 14:42:44 +0200
commit8f803122808e802b8bc0bf7b2ecb057207c5f46f (patch)
tree6c3ffbeb4463b7fd25f8d4b940aa7c1c7360f4a2
parentbb31a53eb2c559d327b6bc7f58735b410ae4815f (diff)
copy into docker
-rw-r--r--.ansible.html.markdown.swlbin0 -> 36864 bytes
-rw-r--r--.ansible.html.markdown.swmbin0 -> 32768 bytes
-rw-r--r--.ansible.html.markdown.swnbin0 -> 61440 bytes
-rw-r--r--ansible.html.markdown32
4 files changed, 30 insertions, 2 deletions
diff --git a/.ansible.html.markdown.swl b/.ansible.html.markdown.swl
new file mode 100644
index 00000000..94a17a7d
--- /dev/null
+++ b/.ansible.html.markdown.swl
Binary files differ
diff --git a/.ansible.html.markdown.swm b/.ansible.html.markdown.swm
new file mode 100644
index 00000000..ff91c7a0
--- /dev/null
+++ b/.ansible.html.markdown.swm
Binary files differ
diff --git a/.ansible.html.markdown.swn b/.ansible.html.markdown.swn
new file mode 100644
index 00000000..25fce1a6
--- /dev/null
+++ b/.ansible.html.markdown.swn
Binary files differ
diff --git a/ansible.html.markdown b/ansible.html.markdown
index e41d1a6a..53ea153f 100644
--- a/ansible.html.markdown
+++ b/ansible.html.markdown
@@ -178,7 +178,7 @@ user@host:~/$ cd ansible-for-learnXinYminutes
user@host:~/ansible-for-learnXinYminutes$ source environment.sh
$
$ # First lets execute the simple_playbook.yml
-(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbook/simple_playbook.yml
+(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/simple_playbook.yml
```
@@ -186,7 +186,7 @@ Run the above playbook with roles example
```bash
$ source environment.sh
$ # Now we would run the above playbook with roles
-(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/role_example.yml
+(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/simple_role.yml
```
#### Role directory structure:
@@ -206,6 +206,15 @@ roles/
Handlers are a tasks that can be triggered (notified) during execution of a playbook, but they itself execute at the very end of a playbook.
It is a best way to restart a service, check if application port is active (successfull deployment criteria), etc.
+Please get familiar how you can use role in simple_apache_role example
+```
+playbooks/roles/simple_apache_role/
+├── tasks
+│   └── main.yml
+└── templates
+ └── main.yml
+```
+
### ansible - variables
Ansible is flexible - it has 21 levels of variable precedence
@@ -223,11 +232,29 @@ You should also know, that a nice way to pool some data is a **lookup**
* stream
* etcd
+```bash
+# read playbooks/lookup.yml
+# run
+(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/lookup.yml
+```
+
You can use them in CLI too
```yaml
ansible -m shell -a 'echo "{{ my_variable }}"' -e 'my_variable="{{ lookup("pipe", "date") }}"' localhost
ansible -m shell -a 'echo "{{ my_variable }}"' -e 'my_variable="{{ lookup("pipe", "hostname") }}"' all
+# Or use in playbook
+
+(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/lookup.yml
+
+```
+
+### Register
+Another way to dynamicaly generate the variable content is a `register` command
+`Register` is also useful to store an output of a task, and use it's value as a logic
+for execution further tasks.
+```
+(venv) user@host:~/ansible-for-learnXinYminutes$ ansible-playbook playbooks/register_and_when.yml
```
### Templates
@@ -259,6 +286,7 @@ Junja is powerfull. It has built-in many usefull functions.
# if variable is undefined - use default value
{{ some_variable | default('default_value') }}
```
+### ansible - tags, limmit, diff, check_mode
### ansible-vault
To maintain **ifrastructure as a code** you need to store secrets.