Changes between Version 81 and Version 82 of GENIExperimenter/Tutorials/AnsibleHelloGENI/Execute


Ignore:
Timestamp:
03/08/21 03:37:08 (3 years ago)
Author:
tristan.jordan@uky.edu
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GENIExperimenter/Tutorials/AnsibleHelloGENI/Execute

    v81 v82  
    134134               </td>
    135135               <td>
    136                     The following are some example Ansible Ad Hoc commands.  You can run these commands one at a time from the machine where you have Ansible installed. `-s` tells Ansible to use `sudo` when executing the command.  All modules are described in the <a href="http://docs.ansible.com/modules_by_category.html">Ansible Documentation</a>.
    137                </td>
    138         </tr>
    139 </table>
    140 }}}
    141 
    142 
    143 [http://docs.ansible.com/apt_module.html `apt`] module is used to install packages using the `apt` package manager:
    144    {{{
    145 #!sh
    146 ansible [-i inventory] [all/server/client] -s -m apt -a "name=apache2 update_cache=yes"
    147    }}}
    148 
    149 [http://docs.ansible.com/command_module.html `command`] module is used to execute an arbitrary command on the remote node:
    150    {{{
    151 #!sh
    152 ansible [-i inventory] [all/server/client]  -s -m command -a "/usr/sbin/a2enmod status"
    153    }}}
    154 [http://docs.ansible.com/file_module.html `file`] module is used to set attributes of files:
    155    {{{
    156 #!sh
    157 ansible [-i inventory] [all/server/client] -s -m file -a "path=/var/www/html state=absent"
    158    }}}
    159 [http://docs.ansible.com/synchronize_module.html `synchronize`] module is an implementation of `rsync` and is used to efficiently synchronize files between your local machine and a remote node:
    160 
    161    {{{
    162 #!sh
    163 ansible [-i inventory] [all/server/client] -s  -m synchronize \
     136                    The following are some example Ansible Ad Hoc commands.  You can run these commands one at a time from the machine where you have Ansible installed. `-b` tells Ansible to use `sudo` when executing the command.  All modules are described in the <a href="https://docs.ansible.com/ansible/latest/user_guide/modules_intro.html">Ansible Documentation</a>.
     137               </td>
     138        </tr>
     139</table>
     140}}}
     141
     142
     143[https://docs.ansible.com/ansible/2.3/apt_module.html `apt`] module is used to install packages using the `apt` package manager:
     144   {{{
     145#!sh
     146ansible [-i inventory] [all/server/client] -b -m apt -a "name=apache2 update_cache=yes"
     147   }}}
     148
     149[https://docs.ansible.com/ansible/2.3/command_module.html `command`] module is used to execute an arbitrary command on the remote node:
     150   {{{
     151#!sh
     152ansible [-i inventory] [all/server/client]  -b -m command -a "/usr/sbin/a2enmod status"
     153   }}}
     154[https://docs.ansible.com/ansible/2.3/file_module.html `file`] module is used to set attributes of files:
     155   {{{
     156#!sh
     157ansible [-i inventory] [all/server/client] -b -m file -a "path=/var/www/html state=absent"
     158   }}}
     159[https://docs.ansible.com/ansible/2.4/synchronize_module.html `synchronize`] module is an implementation of `rsync` and is used to efficiently synchronize files between your local machine and a remote node:
     160
     161   {{{
     162#!sh
     163ansible [-i inventory] [all/server/client] -b  -m synchronize \
    164164    -a "src=website/index.html dest=/var/www"
    165165   }}}
    166 [http://docs.ansible.com/lineinfile_module.html `lineinfile`] module is used to see if an arbitrary line exists in a file:
    167    {{{
    168 #!sh
    169 ansible [-i inventory] [all/server/client] -s  -m lineinfile \
     166[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html `lineinfile`] module is used to see if an arbitrary line exists in a file:
     167   {{{
     168#!sh
     169ansible [-i inventory] [all/server/client] -b  -m lineinfile \
    170170     -a "line='ExtendedStatus On' dest=/etc/apache2/conf.d/extendedstatus create=yes state=present"
    171171   }}}
    172 [http://docs.ansible.com/service_module.html `service`] module is used to start/stop/restart/etc services:
    173    {{{
    174 #!sh
    175 ansible [-i inventory] [all/server/client] -s  -m service -a "name=apache2 state=restarted"
     172[https://docs.ansible.com/ansible/2.9_ja/modules/service_module.html `service`] module is used to start/stop/restart/etc services:
     173   {{{
     174#!sh
     175ansible [-i inventory] [all/server/client] -b  -m service -a "name=apache2 state=restarted"
    176176   }}}
    177177}}}
     
    232232- name: Configure client
    233233  hosts: client
    234   sudo: True
    235234  tasks:
    236235   - name: install apache2
    237236     apt: name=apache2 update_cache=yes
     237     become: yes
    238238   - name: install iperf
    239239     apt: name=iperf update_cache=yes
     240     become: yes
    240241   - name: copy scripts into /local with permissions 755
    241242     synchronize: src=scripts dest=/local mode=755
    242243    }}}
     244     become: yes
    243245
    244246''Do these commands look like the Ad Hoc commands you came up with in the previous step?''
     
    263265- name: Configure server
    264266  hosts: server
    265   sudo: True
    266267  tasks:
    267268   - name: install apache2
    268269     apt: name=apache2 update_cache=yes
     270     become: yes
    269271   - name: install iperf
    270272     apt: name=iperf update_cache=yes
     273     become: yes
    271274   - name: /usr/sbin/a2enmod status
    272275     # INSERT COMMAND HERE
     
    331334   {{{
    332335#!sh
    333 ansible -i inventory server -s -m shell -a "iperf -s -i 10 &> /var/www/iperflogs/iperf-server.log"
     336ansible -i inventory server -b -m shell -a "iperf -s -i 10 &> /var/www/iperflogs/iperf-server.log"
    334337}}}
    335338On the local node do:
    336339   {{{
    337340#!sh
    338 ansible -i inventory client -s -m shell -a "/local/scripts/client-wget.sh &"
    339 ansible -i inventory client -s -m shell -a "/local/scripts/client-iperf.sh &"
     341ansible -i inventory client -b -m shell -a "/local/scripts/client-wget.sh &"
     342ansible -i inventory client -b -m shell -a "/local/scripts/client-iperf.sh &"
    340343   }}}
    341344}}}