<jupyter_start><jupyter_text>Run the Ansible on Jupyter Notebook x Ubuntu- Author: <NAME> / chusiang (at) drx.tw- GitHub: [chusiang/ansible-jupyter.dockerfile](https://github.com/chusiang/ansible-jupyter.dockerfile)- Docker Hub: [chusiang/ansible-jupyter](https://hub.docker.com/r/chusiang/ansible-jupyter/) Table of contexts:1. [Operating-System](Operating-System)1. [Ad-Hoc-commands](Ad-Hoc-commands)1. [Playbooks](Playbooks) Modified.<jupyter_code>!date<jupyter_output>Mon Jun 18 08:18:29 UTC 2018<jupyter_text>Operating SystemCheck the runtime user.<jupyter_code>!whoami<jupyter_output>root<jupyter_text>Show Linux distribution.<jupyter_code>!cat /etc/issue<jupyter_output>Ubuntu 18.04 LTS \n \l<jupyter_text>Workspace.<jupyter_code>!pwd<jupyter_output>/home<jupyter_text>Show Python version.<jupyter_code>!python --version<jupyter_output>Python 2.7.15rc1<jupyter_text>Show pip version.<jupyter_code>!pip --version<jupyter_output>pip 10.0.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)<jupyter_text>Show Ansible version.<jupyter_code>!ansible --version<jupyter_output>ansible 2.5.4
  config file = /home/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]<jupyter_text>Show Jupyter version.<jupyter_code>!jupyter --version<jupyter_output>4.4.0<jupyter_text>AnsibleCheck the playbook syntax, if you see the `[WARNING]`, please fix something, first.<jupyter_code>!ansible-playbook --syntax-check setup_jupyter.yml<jupyter_output>playbook: setup_jupyter.yml<jupyter_text>Ad-Hoc commands ping the localhost.<jupyter_code>!ansible localhost -m ping<jupyter_output>[0;32mlocalhost | SUCCESS => {[0m
[0;32m    "changed": false, [0m
[0;32m    "ping": "pong"[0m
[0;32m}[0m<jupyter_text>Get the facts with `setup` module.<jupyter_code>!ansible localhost -m setup<jupyter_output>[0;32mlocalhost | SUCCESS => {[0m
[0;32m    "ansible_facts": {[0m
[0;32m        "ansible_apparmor": {[0m
[0;32m            "status": "disabled"[0m
[0;32m        }, [0m
[0;32m        "ansible_architecture": "x86_64", [0m
[0;32m        "ansible_bios_date": "03/14/2014", [0m
[0;32m        "ansible_bios_version": "1.00", [0m
[0;32m        "ansible_cmdline": {[0m
[0;32m            "BOOT_IMAGE": "/boot/kernel", [0m
[0;32m            "console": "ttyS0", [0m
[0;32m            "ntp": "gateway", [0m
[0;32m            "page_poison": "1", [0m
[0;32m            "panic": "1", [0m
[0;32m            "root": "/dev/sr0", [0m
[0;32m            "text": true, [0m
[0;32m            "vsyscall": "emulate"[0m
[0;32m        }, [0m
[0;32m        "ansible_date_time": {[0m
[0;32m            "date": "2018-06-18", [0m
[0;32m            "day": "18", [0m
[0;32m            "epoch": "1529309926", [0m
[0;32m            "hour": "08", [0m
[0;32m         [...]<jupyter_text>Remove the **vim** with **apt** package management on **Ubuntu**.<jupyter_code>!ansible localhost -m apt -a 'name=vim state=absent'<jupyter_output>[0;33mlocalhost | SUCCESS => {[0m
[0;33m    "changed": true, [0m
[0;33m    "stderr": "", [0m
[0;33m    "stderr_lines": [], [0m
[0;33m    "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following packages were automatically installed and are no longer required:\n  libpython3.6 vim-common vim-runtime xxd\nUse 'apt autoremove' to remove them.\nThe following packages will be REMOVED:\n  vim\n0 upgraded, 0 newly installed, 1 to remove and 5 not upgraded.\nAfter this operation, 2852 kB disk space will be freed.\n(Reading database ... \r(Reading database ... 5%\r(Reading database ... 10%\r(Reading database ... 15%\r(Reading database ... 20%\r(Reading database ... 25%\r(Reading database ... 30%\r(Reading database ... 35%\r(Reading database ... 40%\r(Reading database ... 45%\r(Reading database ... 50%\r(Reading database ... 55%\r(Reading database ... 60%\r(Reading database ... 65%\r(Reading database ... 70%\r(Reading database ... [...]<jupyter_text>Install the **vim** with **apt** package management on **Ubuntu**.<jupyter_code>!ansible localhost -m apt -a 'name=vim state=present'<jupyter_output>[0;33mlocalhost | SUCCESS => {[0m
[0;33m    "cache_update_time": 1529309580, [0m
[0;33m    "cache_updated": false, [0m
[0;33m    "changed": true, [0m
[0;33m    "stderr": "debconf: delaying package configuration, since apt-utils is not installed\n", [0m
[0;33m    "stderr_lines": [[0m
[0;33m        "debconf: delaying package configuration, since apt-utils is not installed"[0m
[0;33m    ], [0m
[0;33m    "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nSuggested packages:\n  ctags vim-doc vim-scripts\nThe following NEW packages will be installed:\n  vim\n0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.\nNeed to get 1152 kB of archives.\nAfter this operation, 2852 kB of additional disk space will be used.\nGet:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 vim amd64 2:8.0.1453-1ubuntu1 [1152 kB]\nFetched 1152 kB in 3s (411 kB/s)\nSelecting previously unselected package vim.\r\n(Reading database ... \[...]<jupyter_text>Install the **tree** with **apt** package management on **Ubuntu**.<jupyter_code>!ansible localhost -m apt -a 'name=tree state=present'
!tree .<jupyter_output>.
|-- ansible.cfg
|-- ansible_on_jupyter.ipynb
|-- ansible_on_jupyter_ubuntu.ipynb
|-- inventory
`-- setup_jupyter.yml

0 directories, 5 files<jupyter_text>PlaybooksShow `setup_jupyter.yml` playbook.<jupyter_code>!cat setup_jupyter.yml<jupyter_output>---

- name: "Setup Ansible-Jupyter"
  hosts: localhost

  vars:

    # General package on GNU/Linux.
    general_packages:
      - bash
      - bash-completion
      - ca-certificates
      - curl
      - git
      - openssl
      - sshpass

    # Alpine Linux.
    apk_packages:
      - openssh-client
      - vim

    # Debian, Ubuntu.
    apt_packages: "{{ apk_packages }}"

    # Arch Linux.
    pacman_packages:
      - openssh
      - vim

    # Gentoo Linux.
    portage_packages:
      - bash
      - bash-completion
      - ca-certificates
      - dev-vcs/git
      - net-misc/curl
      - openssh
      - openssl
      - sqlite
      - vim

    # CentOS.
    yum_packages:
      - openssh-clients
      - vim-minimal

    # openSUSE.
    zypper_packages: "{{ pacman_packages }}"

    # Python.
    pip_packages:
      - docker-py
      - docker-compose

    jupyter_notebook_config_py_url: "https://raw.githubusercontent.com/chusiang/[...]<jupyter_text>Run the `setup_jupyter.yml` playbook.<jupyter_code>!ansible-playbook setup_jupyter.yml<jupyter_output>PLAY [Setup Ansible-Jupyter] ***************************************************

TASK [Gathering Facts] *********************************************************
[0;32mok: [localhost][0m

TASK [Install general linux packages] ******************************************
[0;32mok: [localhost] => (item=bash)[0m
[0;32mok: [localhost] => (item=bash-completion)[0m
[0;32mok: [localhost] => (item=ca-certificates)[0m
[0;32mok: [localhost] => (item=curl)[0m
[0;32mok: [localhost] => (item=git)[0m
[0;32mok: [localhost] => (item=openssl)[0m
[0;32mok: [localhost] => (item=sshpass)[0m

TASK [Install apk packages on Alpine Linux] ************************************
[0;36mskipping: [localhost] => (item=[]) [0m

TASK [Install apt packages on Debian and Ubuntu] *******************************
[0;32mok: [localhost] => (item=[u'openssh-client', u'vim'])[0m

TASK [Install pacman packages on Arch Linux] ***********************************
[0;36mskipping: [localhost] => (item=[]) [0m

[...]
{'fraction_non_alphanumeric': 0.18934539515014448, 'fraction_numerical': 0.04988063827113959, 'mean_word_length': 3.7721822541966428, 'pattern_counts': {'":': 32, '<': 50, '<?xml version=': 0, '>': 64, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '23603', 'license': 'MIT', 'n_tokens_mistral': 3394, 'n_tokens_neox': 2895, 'n_words': 527, 'path': 'ipynb/ansible_on_jupyter_ubuntu.ipynb', 'repo_name': 'KyleChou/ansible-jupyter.dockerfile', 'size': '7966'}