Top Banner
Ansible - Faster Than Light Bernhard Hopfenmüller 5. Februar 2019
45

Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

Jul 15, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

Ansible - Faster Than Light

Bernhard Hopfenmüller

5. Februar 2019

Page 2: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Introduce myself] ***************

ok: [localhost] => {"me": {

"name": "Bernhard Hopfenmüller","occupation": "Consultant/Developer@Atix","irc_twitter_github": "Fobhep",

}}

#atix #cfgmgmtcamp2019

Page 3: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Describe the Problem] ***********

I start a playbook

I and wait

I and wait

I and wait

I and wait?

I and wait

I and be done

#atix #cfgmgmtcamp2019

Page 4: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Describe the Problem] ***********

I start a playbook

I and wait

I and wait

I and wait

I and wait?

I and wait

I and be done

#atix #cfgmgmtcamp2019

Page 5: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Describe the Problem] ***********

I start a playbook

I and wait

I and wait

I and wait

I and wait?

I and wait

I and be done

#atix #cfgmgmtcamp2019

Page 6: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Describe the Problem] ***********

I start a playbook

I and wait

I and wait

I and wait

I and wait?

I and wait

I and be done

#atix #cfgmgmtcamp2019

Page 7: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Describe the Problem] ***********

I start a playbook

I and wait

I and wait

I and wait

I and wait?

I and wait

I and be done

#atix #cfgmgmtcamp2019

Page 8: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Describe the Problem] ***********

I start a playbook

I and wait

I and wait

I and wait

I and wait?

I and wait

I and be done

#atix #cfgmgmtcamp2019

Page 9: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Describe the Problem] ***********

I start a playbook

I and wait

I and wait

I and wait

I and wait?

I and wait

I and be done

#atix #cfgmgmtcamp2019

Page 10: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [The Name] *******************

imdb.com

#atix #cfgmgmtcamp2019

Page 11: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [The Question] ****************

ok: [localhost] => {"msg": "How do we get there?"

}

#atix #cfgmgmtcamp2019

Page 12: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [ Categories of Optimization] ******

ok: [localhost] => {"tweaks": [

"settings","layer8optimization","mitogen"]

}

#atix #cfgmgmtcamp2019

Page 13: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Debug task duration - Profiling] *****

[defaults]callback_whitelist = profile_tasks

export PROFILE_TASKS_SORT_ORDER=none

ok: [localhost] => {"profiling": "duration of each task"}

#atix #cfgmgmtcamp2019

Page 14: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Test Method] *******************

---- hosts: web1

gather_facts: notasks:

- name: Create directoryfile:

path: /tmp/ansible_speedstate: directory

- name: Create Filesinclude: create_file.yamlloop: "{{ range(0, 10)|list }}"

- name: Remove directoryfile:

path: /tmp/ansible_speedstate: absent

#atix #cfgmgmtcamp2019

Page 15: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Disclaimer] ********************

ok: [localhost] => {"tweaks": {

"testing" : "30 times w/wo tweaks","tests" : "tested each tweak independently ","results" : "qualitative","disclaimer " : "no guarantee for reproducibility",}

}

#atix #cfgmgmtcamp2019

Page 16: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [ Categories of Optimization] *******

ok: [localhost] => {"category" : "settings"}

#atix #cfgmgmtcamp2019

Page 17: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [SSH Pipelining] *****************

[ssh]pipelining = true

ok: [localhost] => {"reuse": "one ssh tunnel","Needs!" : "requiretty=false on managed host!"}

#atix #cfgmgmtcamp2019

Page 18: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Pipelining Benchmark] ************

#atix #cfgmgmtcamp2019

Page 19: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [SSH Pipelining Result] ************

ok: [localhost] => {"msg" : "factor 1.5"}

#atix #cfgmgmtcamp2019

Page 20: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [SSH Multiplexing] ***************

[ssh]ssh_args = -o ControlMaster=auto -o ControlPersist=60s

ok: [localhost] => {"parallel" : "usage of connection","enabled" : "per default",}

#atix #cfgmgmtcamp2019

Page 21: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Multiplexing Benchmark] **********

#atix #cfgmgmtcamp2019

Page 22: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Multiplexing Result] *************

ok: [localhost] => {"msg" : "factor 4.3"}

#atix #cfgmgmtcamp2019

Page 23: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Fork] ************************

[defaults]forks = 5

ok: [localhost] => {"forks": {

"# of parallel processes": "# parallel hosts","too few forks" : "multiplexing closed","here":"no tests",

}}

#atix #cfgmgmtcamp2019

Page 24: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Internal Poll] *******************

[defaults]internal_poll_interval = 0.001

ok: [localhost] => {"interval" : "internal ansible process polling","msg" : "Greater interval means less CPU Load",}

#atix #cfgmgmtcamp2019

Page 25: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Internal Poll Benchmark] **********

#atix #cfgmgmtcamp2019

Page 26: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Internal Poll Result] **************

ok: [localhost] => {"tweaking" : "here not really time wise improvement","relevant" : "CPU load",

}

#atix #cfgmgmtcamp2019

Page 27: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [ Categories of Optimization] *******

ok: [localhost] => {"category" : "layer8optimization"}

#atix #cfgmgmtcamp2019

Page 28: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [No Fact Gathering] **************

---- hosts: web1

gather_facts: no

ok: [localhost] => {"facts" : "do I really need them?","facts" : "do I need them now?","facts" : "consider fact cache!",}

#atix #cfgmgmtcamp2019

Page 29: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Fact Gathering Benchmark] ********

#atix #cfgmgmtcamp2019

Page 30: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Fact Gathering Result] ************

ok: [localhost] => {"msg" : "it's bigger on the inside",}

#atix #cfgmgmtcamp2019

Page 31: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Pull mode] *********************

ansible-pull -U mygit.com/baseline baseline_playbook.yaml

ok: [localhost] => {"use_pull": [

"no need for ssh","combine with Cron","self managing host",

]}

#atix #cfgmgmtcamp2019

Page 32: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Do not loop] *******************

- name: Install packages in looppackage:

name: "{{ item }}"state: present

loop: "{{ packages }}"

- name: Install packages without looppackage:

name: "{{ packages }}"state: present

#atix #cfgmgmtcamp2019

Page 33: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Do noot loop Benchmark] **********

#atix #cfgmgmtcamp2019

Page 34: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Do not loop Result] **************

ok: [localhost] => {"list_of" : "6 packages","factor" : " 2","seems":" independently from package number",

}

#atix #cfgmgmtcamp2019

Page 35: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Further tweaks] *****************

ok: [localhost] => {"honorable_mentions": {"free strategy" : "might help","server installation" : "golden image","move" : "master close to slaves!","general" : "optimize data flow",}

}

#atix #cfgmgmtcamp2019

Page 36: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [ Categories of Optimization] *******

ok: [localhost] => {"category" : "Mitogen"}

#atix #cfgmgmtcamp2019

Page 37: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [A small excursus] ***************

ok: [localhost] => {"msg": " o -> 0 -> 8 -> o o "

}

#atix #cfgmgmtcamp2019

Page 38: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [A small excursus] ***************

ok: [localhost] => {"msg": " o -> 0 -> 8 -> o o "

}

ok: [localhost] => {"msg": "division of cell nuclei, triggered by mitogen"

}

#atix #cfgmgmtcamp2019

Page 39: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Mitogen] *********************

ok: [localhost] => {"mitogen": {

"described as" : "network-capable fork() on steroids",

"replicate" :"itself","distribute": "itself","connection":"1/target","runs":"ephemeral",

}}

src: mitogen docs

#atix #cfgmgmtcamp2019

Page 40: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Mitogen] *********************

[defaults]strategy_plugins = /path/to/mitogenstrategy = mitogen_linear

#atix #cfgmgmtcamp2019

Page 41: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Mitogen Benchmark] *************

#atix #cfgmgmtcamp2019

Page 42: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Mitogen Result] *****************

ok: [localhost] => {"msg" : "factor 12","docs claim": "factor 1.5 - 7"}

#atix #cfgmgmtcamp2019

Page 43: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

SUMMARY *************************

Tuesday 5 February 18:20:00 +0000 (0:00:00.000)===============================================SSH Pipelining ------------------------------- +SSH Multiplexing ----------------------------- 0Fork ---------------------------------------- +Internal Poll -------------------------------- 0No Fact Gathering ---------------------------- +Pull mode ------------------------------------ +Do not loop ---------------------------------- ++Async ---------------------------------------- +Free Strategy -------------------------------- +golden image --------------------------------- +wan to lan ----------------------------------- ++Mitogen -------------------------------------- +++

#atix #cfgmgmtcamp2019

Page 44: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

30s, please ;-)

#atix #cfgmgmtcamp2019

Page 45: Ansible - Faster Than Light · TASK[DescribetheProblem]***** I startaplaybook I andwait I andwait I andwait I andwait? I andwait I andbedone #atix#cfgmgmtcamp2019

TASK [Mitogen vs Pipelining] ************

ok: [localhost] => {"honorable_mentions": {"similarity" : "yes","caching of code" : "mitogen","python processes" : "reused in mitogen","SSH stdio pipeline" : "reused in mitogen",}

}

#atix #cfgmgmtcamp2019