diff --git a/main.yml b/main.yml index ab42e64..fbd665b 100644 --- a/main.yml +++ b/main.yml @@ -1,116 +1,116 @@ --- - name: Create Instances hosts: 127.0.0.1 connection: local gather_facts: false vars_files: - "vars/main.yml" tasks: - include: tasks/create-instances.yml - name: Configure Jump Server hosts: lbs vars_files: - "vars/main.yml" user: centos sudo: yes roles: - role: common tags: [ 'common' ] - role: swap/roles/swap tags: [ 'common' ] # - role: sensu # sensu_rabbitmq_host: "{{ groups['monit'][0] }}" - role: ganglia-gmond - role: haproxy - role: jump - role: nfs nfs_server_daemon: nfs-server # doesn't work as it's in vars not default handlers: - include: handlers/main.yml - name: Configure Monitoring Server hosts: monit vars_files: - "vars/main.yml" user: centos sudo: yes roles: - role: common tags: [ 'common' ] - role: swap/roles/swap tags: [ 'common' ] - role: nginx nginx_config: nginx-monit.conf - role: ganglia-gmond - role: ganglia-gmetad # - role: rabbitmq # - role: redis # - role: uchiwa # - role: sensu # sensu_install_server: true # sensu_install_api: true handlers: - include: handlers/main.yml - name: Configure Databases hosts: dbs vars_files: - "vars/main.yml" user: centos sudo: yes roles: - role: common tags: [ 'common' ] - role: swap/roles/swap tags: [ 'common' ] - role: ganglia-gmond # - role: sensu # sensu_rabbitmq_host: "{{ groups['monit'][0] }}" - role: galera handlers: - include: handlers/main.yml - name: Configure App hosts: app vars_files: - "vars/main.yml" user: centos sudo: yes roles: - role: common tags: [ 'common' ] - role: swap/roles/swap tags: [ 'common' ] - role: ganglia-gmond # - role: sensu # sensu_rabbitmq_host: "{{ groups['monit'][0] }}" - { role: nginx, nginx_config: nginx-phabricator.conf } - role: phabricator handlers: - include: handlers/main.yml -#- name: Configure Jenkins -# hosts: ci -# vars_files: -# - "vars/main.yml" -# user: centos -# sudo: yes -# roles: -# - role: common -# tags: [ 'common' ] -# - role: swap/roles/swap -# tags: [ 'common' ] -# - role: ganglia-gmond -## - role: sensu -## sensu_rabbitmq_host: "{{ groups['monit'][0] }}" -# - role: jenkins -# plugins: -# - 'ldap' -# - 'preSCMbuildstep' -# prefix: '/build' -# email: -# smtp_host: 'mail.epfl.ch' -# smtp_ssl: 'true' -# default_email_suffix: '@epfl.ch' -# +- name: Configure Jenkins + hosts: ci + vars_files: + - "vars/main.yml" + user: centos + sudo: yes + roles: + - role: common + tags: [ 'common' ] + - role: swap/roles/swap + tags: [ 'common' ] + - role: ganglia-gmond +# - role: sensu +# sensu_rabbitmq_host: "{{ groups['monit'][0] }}" + - role: jenkins + plugins: + - 'ldap' + - 'preSCMbuildstep' + prefix: '/build' + email: + smtp_host: 'mail.epfl.ch' + smtp_ssl: 'true' + default_email_suffix: '@epfl.ch' + diff --git a/roles/haproxy/templates/haproxy.cfg.j2 b/roles/haproxy/templates/haproxy.cfg.j2 index 2892326..61eaac9 100644 --- a/roles/haproxy/templates/haproxy.cfg.j2 +++ b/roles/haproxy/templates/haproxy.cfg.j2 @@ -1,98 +1,96 @@ global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user root group root daemon # turn on stats unix socket stats socket /var/lib/haproxy/stats level admin defaults log global option dontlognull option forceclose option redispatch retries 3 #timeout http-request 10s #timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m #timeout http-keep-alive 10s #timeout check 10s maxconn 3000 frontend public bind *:80 default_backend app backend app mode http option httplog balance static-rr {% for host in groups['app'] %} server {{ hostvars[host]['host_name'] }} {{ host }}:80 check send-proxy {% endfor %} frontend monit bind *:{{ monit_port }} default_backend monitd backend monitd mode http {% for host in groups['monit'] %} server {{ hostvars[host]['host_name'] }} {{ host }}:80 send-proxy {% endfor %} frontend sshd bind *:{{ vcs_port }} default_backend ssh timeout client 1h backend ssh mode tcp option tcplog {% for host in groups['app'] %} server {{ hostvars[host]['host_name'] }} {{ host }}:{{ vcs_port }} check port {{ vcs_port }} {% endfor %} frontend mysqld bind *:3306 default_backend mysql backend mysql mode tcp option tcplog balance static-rr {% for host in groups['dbs'] %} server {{ hostvars[host]['host_name'] }} {{ host }}:3306 check port 3306 {% endfor %} listen haproxy-monit 0.0.0.0:{{ stats_port }} mode http stats enable stats refresh 5s stats show-legends stats uri / stats realm Stats stats auth test:test stats admin if TRUE -{# -#frontend ci -# bind *:{{ jenkins_port }} -# default_backend ci -# -#backend ci -# mode http -# option httplog -# balance static-rr -# {% for host in groups['ci'] %} -# server {{ hostvars[host]['host_name']}} {{ host }}:{{ jenkins_port }} check -# {% endfor %} -#} +frontend ci + bind *:{{ jenkins_port }} + default_backend ci + +backend ci + mode http + option httplog + balance static-rr + {% for host in groups['ci'] %} + server {{ hostvars[host]['host_name']}} {{ host }}:{{ jenkins_port }} check + {% endfor %} diff --git a/tasks/create-instances.yml b/tasks/create-instances.yml index 1923869..273eb24 100644 --- a/tasks/create-instances.yml +++ b/tasks/create-instances.yml @@ -1,232 +1,229 @@ --- # Security group - os_security_group: state: present name: all description: The world famous any any rule - os_security_group_rule: security_group: all direction: egress - os_security_group_rule: security_group: all protocol: icmp remote_ip_prefix: 0.0.0.0/0 - os_security_group_rule: security_group: all protocol: tcp port_range_min: 1 port_range_max: 65535 remote_ip_prefix: 0.0.0.0/0 - os_security_group_rule: security_group: all protocol: udp port_range_min: 1 port_range_max: 65535 remote_ip_prefix: 0.0.0.0/0 # Create instances - name: Create jump os_server: state: present security_groups: all name: c4science-jump image: "{{ image_id }}" key_name: "{{ keypair_name }}" wait: yes floating_ips: - "{{ external_ip }}" nics: - net-id: "{{ private_net}}" flavor: "{{ flavor_id_small }}" meta: hostname: c4science-jump group: ansible register: openstackjump - add_host: name: "{{ openstackjump.openstack.public_v4 }}" private_ip: "{{ openstackjump.openstack.private_v4 }}" host_name: "c4science-jump" groupname: lbs - name: Create App1 os_server: state: present security_groups: all name: c4science-app01 image: "{{ image_id }}" key_name: "{{ keypair_name }}" wait: yes auto_ip: no nics: - net-id: "{{ private_net}}" flavor: "{{ flavor_id_small }}" meta: hostname: c4science-app01 group: ansible register: openstackapp1 - add_host: name: "{{ openstackapp1.openstack.private_v4 }}" private_ip: "{{ openstackapp1.openstack.private_v4 }}" host_name: "c4science-app01" groupname: app - name: Create App2 os_server: state: present security_groups: all name: c4science-app02 image: "{{ image_id }}" key_name: "{{ keypair_name }}" wait: yes auto_ip: no nics: - net-id: "{{ private_net}}" flavor: "{{ flavor_id_small }}" meta: hostname: c4science-app02 group: ansible register: openstackapp2 - add_host: name: "{{ openstackapp2.openstack.private_v4 }}" private_ip: "{{ openstackapp2.openstack.private_v4 }}" host_name: "c4science-app02" groupname: app - name: Create Db1 os_server: state: present security_groups: all name: c4science-db01 image: "{{ image_id }}" key_name: "{{ keypair_name }}" wait: yes auto_ip: no nics: - net-id: "{{ private_net}}" flavor: "{{ flavor_id_small }}" meta: hostname: c4science-db01 group: ansible register: openstackdb1 - add_host: name: "{{ openstackdb1.openstack.private_v4 }}" private_ip: "{{ openstackdb1.openstack.private_v4 }}" host_name: "c4science-db01" groupname: dbs - name: Create Db2 os_server: state: present security_groups: all name: c4science-db02 image: "{{ image_id }}" key_name: "{{ keypair_name }}" wait: yes auto_ip: no nics: - net-id: "{{ private_net}}" flavor: "{{ flavor_id_small }}" meta: hostname: c4science-db02 group: ansible register: openstackdb2 - add_host: name: "{{ openstackdb2.openstack.private_v4 }}" private_ip: "{{ openstackdb2.openstack.private_v4 }}" host_name: "c4science-db02" groupname: dbs - name: Create Monitoring instance os_server: state: present security_groups: all name: c4science-monit image: "{{ image_id }}" key_name: "{{ keypair_name }}" wait: yes auto_ip: no nics: - net-id: "{{ private_net}}" flavor: "{{ flavor_id_small }}" meta: hostname: c4science-monit group: ansible register: openstackmonit - add_host: name: "{{ openstackmonit.openstack.private_v4 }}" private_ip: "{{ openstackmonit.openstack.private_v4 }}" host_name: "c4science-monit" groupname: monit -#- name: Create Ci1 -# nova_compute: -# state: present -# auth_url: "{{ auth_url }}" -# login_username: "{{ login_username }}" -# login_password: "{{ login_password }}" -# login_tenant_name: "{{ login_tenant_name }}" -# security_groups: "{{ secgroup_all }}" -# name: c4science-ci01 -# image_id: "{{ image_id }}" -# key_name: "{{ keypair_name }}" -# wait_for: 500 -# nics: -# - net-id: "{{ private_net }}" -# flavor_id: "{{ flavor_id_small }}" -# meta: -# hostname: c4science-ci01 -# group: ansible -# register: openstackci01 -# -#- add_host: -# name: "{{ openstackci01.openstack.private_v4 }}" -# private_ip: "{{ openstackc01.openstack.private_v4 }}" -# host_name: "c4science-ci01" -# groupname: ci +- name: Create Jenkins instance + os_server: + state: present + security_groups: all + name: c4science-ci01 + image: "{{ image_id }}" + key_name: "{{ keypair_name }}" + wait: yes + auto_ip: no + nics: + - net-id: "{{ private_net}}" + flavor: "{{ flavor_id_small }}" + meta: + hostname: c4science-ci01 + group: ansible + register: openstackci01 + +- add_host: + name: "{{ openstackci01.openstack.private_v4 }}" + private_ip: "{{ openstackci01.openstack.private_v4 }}" + host_name: "c4science-ci01" + groupname: ci # Create volumes - name: Create repo volume os_volume: state: present size: 100 display_name: repo-data wait: yes - name: Attach repo volume os_server_volume: state: present server: c4science-jump volume: repo-data device: /dev/vdb - name: get dbs list os_server_facts: server: c4science-db* - name: Create dbs volume os_volume: state: present size: 100 display_name: "{{ item.human_id }}-data" wait: yes with_items: openstack_servers - name: Attach dbs volume os_server_volume: state: present server: "{{ item.human_id }}" volume: "{{ item.human_id }}-data" device: /dev/vdb with_items: openstack_servers