[Up]常用資訊

[重點文章] 重點文章 [重點文章] 重點文章

2020年5月14日 星期四

[Ansible] 使用Ansible 管理顯示 F5 的設備 的設定檔

[Ansible] 使用Ansible 管理顯示 F5 的設備 的設定檔

 
#Step 01 –

指令

 ansible-playbook -i f5-hosts.yaml cmd.yaml -e F5host=ltm01
 
 
#Step 02 –

# cat f5-hosts.yaml

[bigipltm]
ltm01 ansible_host=192.168.96.160
ltm02 ansible_host=192.168.96.161
ltm03 ansible_host=192.168.96.162
ltm04 ansible_host=192.168.96.163
ltm05 ansible_host=192.168.96.164
ltm06 ansible_host=192.168.96.165

[bigipltm:vars]
ansible_python_interpreter=/usr/bin/python3

# cat cmd.yaml

---

- name: "Run a tmsh command"
  hosts: "{{ F5host }}"
  gather_facts: False
  connection: local

  vars:
    validate_certs: no
    server: "{{ ansible_host }}"

  vars_prompt:
    - name: "username"
      prompt: "Enter BIG-IP username"
      private: yes
    - name: "password"
      prompt: "Enter BIG-IP password"
      private: yes

  tasks:
    - name: View system version and LTM configuration
      bigip_command:
        commands:
          - list /ltm virtual all
          - list /ltm pool all
          - list /ltm node all
        provider:
          server: "{{ server }}"
          password: "{{ password }}"
          user: "{{ username }}"
          validate_certs: "{{ validate_certs }}"
      delegate_to: localhost
      register: result

    - debug: msg="{{ result.stdout_lines }}"
 
#Step 03 –

[16:57:03 root@Debian10-3-Jenkins-Ansible-03 ~/F5-playbook]# ansible-playbook -i f5-hosts.yaml f5showcmd1.yaml -e F5host=ltm01
Enter BIG-IP username:
Enter BIG-IP password:

PLAY [Run a tmsh command] ****************************************************************************************************************************************************************************************************

TASK [View system version and LTM configuration] *****************************************************************************************************************************************************************************
ok: [ltm01 -> localhost]

TASK [debug] *****************************************************************************************************************************************************************************************************************
ok: [ltm01] => {
    "msg": [
        [
            "ltm virtual vs_192.168.71.188_HTTP {",
            "    destination 192.168.71.188:http",
            "    ip-protocol tcp",
            "    mask 255.255.255.255",
            "    profiles {",
            "        http { }",
            "        tcp { }",
            "    }",
            "    rules {",
            "        _sys_https_redirect",
            "    }",
            "    serverssl-use-sni disabled",
            "    source 0.0.0.0/0",
            "    translate-address enabled",
            "    translate-port enabled",
            "    vlans {",
            "        External_VPN_valn",
            "    }",
            "    vlans-enabled",
            "    vs-index 16",
            "}"
        ]
    ]
}

PLAY RECAP *******************************************************************************************************************************************************************************************************************
ltm01                      : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

[16:57:26 root@Debian10-3-Jenkins-Ansible-03 ~/F5-playbook]#

 
#Step 04 –


 
#Step 05 –


 
#Step 06 –


 
#Step 07 –


 
#Step 08 –


 
#Step 09 –


 
#Step 10 –


沒有留言:

張貼留言