--- #- hosts: all # sudo: yes # tasks: - name: get last ip address shell: expr substr `cat /etc/hostname` 5 1 register: lastip #- name: "configure interface" ## sudo: True # lineinfile: # dest: "/etc/network/interfaces" # line: "{{ item }}" # with_items: # - "auto {{ contrail_vhost_device }}" # - "iface {{ contrail_vhost_device }} inet static" # - "\taddress {{ contrail_vhost_address }}{{ lastip.stdout_lines[0] }}" # - "\tnetmask {{ contrail_vhost_netmask }}" - name: "set interface address" # sudo: True shell: "ifconfig {{ contrail_vhost_device }} {{ contrail_vhost_address }}{{ lastip.stdout_lines[0] }} netmask {{ contrail_vhost_netmask }}" - name: "up interface" # sudo: True shell: "ifconfig {{ contrail_vhost_device }} up"