АМ
И надо так же перенастроить mikrotik (у меня 2 группы routers и servers с хостами temp и vpn соответсвенно)
Делаю так:
Size: a a a
АМ
АМ
---
- name: Update configuration temp router
hosts: temp,vpn
gather_facts: false
vars_prompt:
- name: sitename
prompt: input name for new site
private: no
default: site_name
- name: MKnum
prompt: input number for this mikrotik on this site (by default 1)
private: no
default: 1
- name: Ovpn_password
prompt: input password for this Mikrotik
private: yes
- name: networkpref
prompt: input next preffix for network 10.100.x.0
private: no
default: 255
# hosts: vpn
vars:
name_mk: "{{sitename}}_MK{{MKnum}}"
tasks:
- name: Create password
ansible.builtin.lineinfile:
path: /etc/ansible/tmp/pwdtest
line: "{{name_mk}} {{Ovpn_password}}"
create: yes
when: "'vpn' in {{group_names}}"
- name: Create ip address for new Site
ansible.builtin.lineinfile:
path: /etc/openvpn/ccd/{{name_mk}}
line: "ifconfig-push 10.100.{{networkpref}}.{{MKnum}} 255.255.0.0"
create: yes
when: "'vpn' in {{group_names}}"
- name: change_name
routeros_command:
commands: /system identity set name="{{sitename}}_Mk{{MKnum}}"
register: system_identity
when: "'temp' in {{group_names}}"
- name: debug print
debug: var=system_identity.stdout_lines
when: "'temp' in {{group_names}}"
АМ
АМ
ММ
ММ
when: '"Empty token" in result.content'
АМ
АМ
ММ
АМ
ММ
АМ
АМ
АМ
АМ
АМ
- name: Speciall ops for special nodes
command: "/usr/bin/special.sh"
when: "'special' in {{ group_names }}"
ММ
- name: Debug
debug:
msg: "Ok"
when:
- '"Empty token" in result.content'
- '"testing" in group_names'
АМ