sudo apt install libffi-dev
Run a playbook with option --step
.
It is called “filter”.
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#product-filters
https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html
If you have a large amount of servers in inventories, -l
option can restrict the target of playbook.
-l Server_group_name
-l FQDN
When your environment has different OSs, systemd
module doesn’t work sometimes.
Instead, I want to recommend to use system`` module. It can handle both
init.d/ and systemd
.
-C
: check = dry run.-b
: become root user in the target system.-D
: Show difference of changes if there is.There are some frequently used operations such as “restarting a webserver (after its configuration is changed)” . If you need the template for such kind of an operation, you’d better to prepare a “handler” for this purpose.
In production deployments, backup=yes
option is regarded as mandatory.
ansible_check_mode
not command
, but shell
.
include_tasks
directive.
{{ role_path }}
with_dict
.
Someties command required prompt and ansible would fail. Here is a sample.
shell: echo "\n\n\n\n\n\n\n\n\n\n" | pecl install {{ item }}
No execution log remained. Basically we don’t need the log if we can write a script to preserve idempotency.
- name: Check PHP version
shell: pecl version
register: pecl_version
- set_fact:
pecl_version={{ pecl_version.stdout }}
- debug: var=pecl_version
ansible-galaxy role init {{ your_role_name }}
Get all targets in an inventory.
ansible-inventory -i inventory --list
Use tags
option.
in tasks: task.yml
- name: Install the package "foo"
apt:
name: foo
state: present
tags: tag1
Exec:
ansible-playbook ./test.yml --tags "tag1"
https://github.com/haidaraM/ansible-playbook-grapher
https://mitogen.networkgenomics.com/ansible_detailed.html
All I had to do to use Mitogen for Ansible was, download the Mitogen source code and refer it from Ansible as described in official document. But there was a version issue. I downloaded release candidate version ()
https://github.com/mitogen-hq/mitogen/pull/715 https://github.com/mitogen-hq/mitogen/issues/652
My understanding of Mitogen is, it enables us to executre remote Python script quick and safe.
[mixed_group:children]
child_group
[mixed_group]
child_host
https://docs.ansible.com/ansible/latest/dev_guide/style_guide/grammar_punctuation.html
https://stackoverflow.com/a/18255256/9923806
Hostname (or IP) and a comma:
ansible-playbook playbooks/master.yml -CD -i 192.168.0.123,