- name: Test Playbook
hosts: localhost
tasks:
- name: Set
set_fact:
test_num: 3
test_network: "10.8.30.1"
- debug:
msg: "{{ test_network.split('.')[:-test_num:-1] | join('.') }}"
- 実行結果
TASK [debug] ********************************************************************************************
ok: [localhost] => {
"msg": "1.30"
}