I have a tomcat server with 200 instances. I have created a playbook for deploying a new server and it works fine, BUT
I have several plays that manipulate numerous files in each tomcat-instance, and the way it is going now is that the ansible-server connects to the target server for each command. and that is very slow, but it works
what I would like was for some speedup to the process by executing more commands pr connection.
instead of:
..
..
- name: create dir structure for tomcats
file:
dest: "/data/tomcat/tomcat-instance{{ item[1] }}/{{ item[0] }}/"
state: directory
owner: root
group: appuser
mode: 0770
recurse: yes
vars:
dirs:
- work
- webapps
- temp
- conf
loop: "{{ dirs | product(range(1, ( tomcat_count +1 | int ) )) | list }}"
## range requieres +1 because last number is not inside the range
- name: create dir structure - log
file:
dest: "/var/log/tomcat-instance{{ item }}"
state: directory
owner: root
group: appuser
mode: 0770
recurse: yes
with_sequence: count={{ tomcat_count }}
- name: create dir structure-links
file:
src: "/opt/tomcat-{{ tomcat_version[0] }}/{{ item [0] }}"
dest: "/data/tomcat/tomcat-instance{{ item[1] }}/{{ item[0] }}"
state: link
vars:
dirs:
- bin
- lib
- webapps/manager
loop: "{{ dirs | product(range(1, ( tomcat_count +1 | int ) )) | list }}"
## range requieres +1 because last number is not inside the range
- name: create config structure-links
file:
src: "/opt/tomcat-{{ tomcat_version[0] }}/conf/{{ item [0] }}"
dest: "/data/tomcat/tomcat-instance{{ item[1] }}/conf/{{ item[0] }}"
state: link
vars:
dirs:
- catalina.properties
- catalina.policy
- web.xml
- tomcat-users.xml
loop: "{{ dirs | product(range(1, ( tomcat_count +1 | int ) )) | list }}"
- name: create dir structure-links log
file:
src: "/var/log/tomcat-instance{{ item }}"
dest: "/data/tomcat/tomcat-instance{{ item }}/logs"
state: link
with_sequence: count={{ tomcat_count }}
- name: create server.xlm port defnitions
vars:
ShutDownPort: "{{ (item|int) * 100 + 8005 }}"
HttpPort: "{{ (item|int) * 100 + 8080 }}"
AjpPort: "{{ (item|int) * 100 + 8009 }}"
JvmRoute: "{{ ansible_hostname }}{{ item }}"
TomcatHome: "/data/tomcat/tomcat-instance{{ item }}"
template:
src: tomcat_server_xlm_template
#dest: /data/tomcat/tomcat-instance{{ item }}/conf/server.xml
dest: /data/tomcat/tomcat-instance{{ item }}/conf/server-7.xml
with_sequence: count={{ tomcat_count }}
..
..
this is just a part of the play and it takes just about forever to run
can I bundle the 'with_sequence' tasks for quicker execution or am I completly off the board with this solution ?