|
6 | 6 | "collapsed": true |
7 | 7 | }, |
8 | 8 | "source": [ |
9 | | - "# Run the Ansible on Jupyter\n", |
| 9 | + "# Run the Ansible on Jupyter Notebook\n", |
10 | 10 | "\n", |
11 | 11 | "- Author: Chu-Siang Lai / chusiang (at) drx.tw\n", |
12 | 12 | "- GitHub: [chusiang/ansible-jupyter.dockerfile](https://github.com/chusiang/ansible-jupyter.dockerfile)\n", |
|
22 | 22 | }, |
23 | 23 | { |
24 | 24 | "cell_type": "code", |
25 | | - "execution_count": 8, |
| 25 | + "execution_count": 9, |
26 | 26 | "metadata": { |
27 | 27 | "collapsed": false |
28 | 28 | }, |
|
31 | 31 | "name": "stdout", |
32 | 32 | "output_type": "stream", |
33 | 33 | "text": [ |
34 | | - "Mon Nov 21 11:30:05 UTC 2016\r\n" |
| 34 | + "Tue Nov 22 06:49:18 UTC 2016\r\n" |
35 | 35 | ] |
36 | 36 | } |
37 | 37 | ], |
|
50 | 50 | }, |
51 | 51 | { |
52 | 52 | "cell_type": "code", |
53 | | - "execution_count": 1, |
| 53 | + "execution_count": 2, |
54 | 54 | "metadata": { |
55 | 55 | "collapsed": false |
56 | 56 | }, |
|
76 | 76 | }, |
77 | 77 | { |
78 | 78 | "cell_type": "code", |
79 | | - "execution_count": 2, |
| 79 | + "execution_count": 3, |
80 | 80 | "metadata": { |
81 | 81 | "collapsed": false |
82 | 82 | }, |
|
95 | 95 | "!cat /etc/issue" |
96 | 96 | ] |
97 | 97 | }, |
| 98 | + { |
| 99 | + "cell_type": "markdown", |
| 100 | + "metadata": {}, |
| 101 | + "source": [ |
| 102 | + "Show Python version." |
| 103 | + ] |
| 104 | + }, |
| 105 | + { |
| 106 | + "cell_type": "code", |
| 107 | + "execution_count": 5, |
| 108 | + "metadata": { |
| 109 | + "collapsed": false |
| 110 | + }, |
| 111 | + "outputs": [ |
| 112 | + { |
| 113 | + "name": "stdout", |
| 114 | + "output_type": "stream", |
| 115 | + "text": [ |
| 116 | + "Python 2.7.12\r\n" |
| 117 | + ] |
| 118 | + } |
| 119 | + ], |
| 120 | + "source": [ |
| 121 | + "!python --version" |
| 122 | + ] |
| 123 | + }, |
| 124 | + { |
| 125 | + "cell_type": "markdown", |
| 126 | + "metadata": {}, |
| 127 | + "source": [ |
| 128 | + "Show pip version." |
| 129 | + ] |
| 130 | + }, |
| 131 | + { |
| 132 | + "cell_type": "code", |
| 133 | + "execution_count": 7, |
| 134 | + "metadata": { |
| 135 | + "collapsed": false |
| 136 | + }, |
| 137 | + "outputs": [ |
| 138 | + { |
| 139 | + "name": "stdout", |
| 140 | + "output_type": "stream", |
| 141 | + "text": [ |
| 142 | + "pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)\r\n" |
| 143 | + ] |
| 144 | + } |
| 145 | + ], |
| 146 | + "source": [ |
| 147 | + "!pip --version" |
| 148 | + ] |
| 149 | + }, |
| 150 | + { |
| 151 | + "cell_type": "markdown", |
| 152 | + "metadata": {}, |
| 153 | + "source": [ |
| 154 | + "Show Ansible version." |
| 155 | + ] |
| 156 | + }, |
| 157 | + { |
| 158 | + "cell_type": "code", |
| 159 | + "execution_count": 6, |
| 160 | + "metadata": { |
| 161 | + "collapsed": false |
| 162 | + }, |
| 163 | + "outputs": [ |
| 164 | + { |
| 165 | + "name": "stdout", |
| 166 | + "output_type": "stream", |
| 167 | + "text": [ |
| 168 | + "ansible 2.2.0.0\r\n", |
| 169 | + " config file = \r\n", |
| 170 | + " configured module search path = Default w/o overrides\r\n" |
| 171 | + ] |
| 172 | + } |
| 173 | + ], |
| 174 | + "source": [ |
| 175 | + "!ansible --version" |
| 176 | + ] |
| 177 | + }, |
| 178 | + { |
| 179 | + "cell_type": "markdown", |
| 180 | + "metadata": {}, |
| 181 | + "source": [ |
| 182 | + "Show Jupyter version." |
| 183 | + ] |
| 184 | + }, |
| 185 | + { |
| 186 | + "cell_type": "code", |
| 187 | + "execution_count": 8, |
| 188 | + "metadata": { |
| 189 | + "collapsed": false |
| 190 | + }, |
| 191 | + "outputs": [ |
| 192 | + { |
| 193 | + "name": "stdout", |
| 194 | + "output_type": "stream", |
| 195 | + "text": [ |
| 196 | + "4.2.0\r\n" |
| 197 | + ] |
| 198 | + } |
| 199 | + ], |
| 200 | + "source": [ |
| 201 | + "!jupyter --version" |
| 202 | + ] |
| 203 | + }, |
98 | 204 | { |
99 | 205 | "cell_type": "markdown", |
100 | 206 | "metadata": {}, |
|
646 | 752 | "- hosts: localhost\r\n", |
647 | 753 | "\r\n", |
648 | 754 | " vars:\r\n", |
649 | | - " os_packages:\r\n", |
| 755 | + " some_packages:\r\n", |
650 | 756 | " - bash\r\n", |
651 | 757 | " - bash-completion\r\n", |
652 | 758 | " - ca-certificates\r\n", |
653 | 759 | " - curl\r\n", |
654 | 760 | " - git\r\n", |
655 | | - " - openssh-client\r\n", |
656 | 761 | " - openssl\r\n", |
| 762 | + "\r\n", |
| 763 | + " apk_packages: \r\n", |
| 764 | + " - openssh-client\r\n", |
657 | 765 | " - vim\r\n", |
| 766 | + "\r\n", |
| 767 | + " apt_packages: \"{{ apk_packages }}\"\r\n", |
| 768 | + "\r\n", |
| 769 | + " yum_packages:\r\n", |
| 770 | + " - openssh-clients\r\n", |
| 771 | + " - vim-minimal\r\n", |
658 | 772 | " \r\n", |
659 | 773 | " pip_packages:\r\n", |
660 | 774 | " - docker-py\r\n", |
661 | 775 | " - docker-compose\r\n", |
662 | 776 | " \r\n", |
663 | 777 | " tasks:\r\n", |
664 | | - " - name: install some apk packages\r\n", |
| 778 | + " - name: install some packages\r\n", |
| 779 | + " package: name={{ item }} state=latest\r\n", |
| 780 | + " with_nested: \"{{ some_packages }}\"\r\n", |
| 781 | + " when:\r\n", |
| 782 | + " - some_packages is defined\r\n", |
| 783 | + "\r\n", |
| 784 | + " - name: install apk packages\r\n", |
665 | 785 | " apk: name={{ item }} state=latest\r\n", |
666 | | - " with_nested: \"{{ os_packages }}\"\r\n", |
| 786 | + " with_nested: \"{{ apk_packages }}\"\r\n", |
667 | 787 | " when:\r\n", |
668 | | - " - os_packages is defined\r\n", |
669 | | - " - ansible_distribution == \"Alpine\"\r\n", |
| 788 | + " - apk_packages is defined\r\n", |
| 789 | + " - ansible_pkg_mgr == \"apk\"\r\n", |
670 | 790 | "\r\n", |
671 | | - " - name: install some apt packages\r\n", |
| 791 | + " - name: install apt packages\r\n", |
672 | 792 | " apt: name={{ item }} state=latest\r\n", |
673 | | - " with_nested: \"{{ os_packages }}\"\r\n", |
| 793 | + " with_nested: \"{{ apt_packages }}\"\r\n", |
| 794 | + " when:\r\n", |
| 795 | + " - apt_packages is defined\r\n", |
| 796 | + " - ansible_pkg_mgr == \"apt\"\r\n", |
| 797 | + "\r\n", |
| 798 | + " - name: install yum packages\r\n", |
| 799 | + " yum: name={{ item }} state=latest\r\n", |
| 800 | + " with_nested: \"{{ yum_packages }}\"\r\n", |
674 | 801 | " when:\r\n", |
675 | | - " - os_packages is defined\r\n", |
676 | | - " - ansible_distribution == \"Ubuntu\"\r\n", |
| 802 | + " - yum_packages is defined\r\n", |
| 803 | + " - ansible_pkg_mgr == \"yum\"\r\n", |
677 | 804 | "\r\n", |
678 | 805 | " - name: install some pip packages\r\n", |
679 | 806 | " pip: name={{ item }} state=latest\r\n", |
|
700 | 827 | }, |
701 | 828 | { |
702 | 829 | "cell_type": "code", |
703 | | - "execution_count": 9, |
| 830 | + "execution_count": 11, |
704 | 831 | "metadata": { |
705 | 832 | "collapsed": false |
706 | 833 | }, |
|
715 | 842 | "TASK [setup] *******************************************************************\n", |
716 | 843 | "\u001b[0;32mok: [localhost]\u001b[0m\n", |
717 | 844 | "\n", |
718 | | - "TASK [install some apk packages] ***********************************************\n", |
719 | | - "\u001b[0;32mok: [localhost] => (item=[u'bash', u'bash-completion', u'ca-certificates', u'curl', u'git', u'openssh-client', u'openssl', u'vim'])\u001b[0m\n", |
| 845 | + "TASK [install some packages] ***************************************************\n", |
| 846 | + "\u001b[0;32mok: [localhost] => (item=[u'bash', u'bash-completion', u'ca-certificates', u'curl', u'git', u'openssl'])\u001b[0m\n", |
| 847 | + "\n", |
| 848 | + "TASK [install apk packages] ****************************************************\n", |
| 849 | + "\u001b[0;32mok: [localhost] => (item=[u'openssh-client', u'vim'])\u001b[0m\n", |
| 850 | + "\n", |
| 851 | + "TASK [install apt packages] ****************************************************\n", |
| 852 | + "\u001b[0;36mskipping: [localhost] => (item=[u'openssh-client', u'vim']) \u001b[0m\n", |
720 | 853 | "\n", |
721 | | - "TASK [install some apt packages] ***********************************************\n", |
722 | | - "\u001b[0;36mskipping: [localhost] => (item=[u'bash', u'bash-completion', u'ca-certificates', u'curl', u'git', u'openssh-client', u'openssl', u'vim']) \u001b[0m\n", |
| 854 | + "TASK [install yum packages] ****************************************************\n", |
| 855 | + "\u001b[0;36mskipping: [localhost] => (item=[u'openssh-clients', u'vim-minimal']) \u001b[0m\n", |
723 | 856 | "\n", |
724 | 857 | "TASK [install some pip packages] ***********************************************\n", |
725 | 858 | "\u001b[0;32mok: [localhost] => (item=[u'docker-py', u'docker-compose'])\u001b[0m\n", |
|
728 | 861 | "\u001b[0;32mok: [localhost]\u001b[0m\n", |
729 | 862 | "\n", |
730 | 863 | "PLAY RECAP *********************************************************************\n", |
731 | | - "\u001b[0;32mlocalhost\u001b[0m : \u001b[0;32mok=4 \u001b[0m changed=0 unreachable=0 failed=0 \n", |
| 864 | + "\u001b[0;32mlocalhost\u001b[0m : \u001b[0;32mok=5 \u001b[0m changed=0 unreachable=0 failed=0 \n", |
732 | 865 | "\n" |
733 | 866 | ] |
734 | 867 | } |
|
0 commit comments