diff --git a/defaults/main.yml b/defaults/main.yml index 7e8f82f..a0f9953 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,6 +7,12 @@ sonarqube_db_image: postgres sonarqube_http_port: 9000 sonarqube_api_port: 9001 +# Limits +sonarqube_vm_max_map_count: 524288 +sonarqube_fs_file_max: 131072 +sonarqube_nofile: 131072 +sonarqube_nproc: 8192 + # Sonarqube paths sonarqube_root_path: /var/local sonarqube_config_path: "{{ sonarqube_root_path }}/conf/sonarqube" diff --git a/tasks/config.yml b/tasks/config.yml index 021f444..a7e8e3f 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -21,3 +21,29 @@ - "{{ sonarqube_configuration_files }}" tags: - sonarqube_configure + +- name: "SONARQUBE | Set up nofiles and nproc for ansible user" + pam_limits: + domain: "*" + limit_type: "{{ item.limit_type }}" + limit_item: "{{ item.limit_item }}" + value: "{{ item.value }}" + loop: + # Add nofile and nproc, both soft and hard, limit for the user db_user with a comment. + # Type "-" for enforcing both soft and hard resource limits together for more details read `man limits.conf`. + - { limit_type: '-', limit_item: 'nofile', value: "{{ sonarqube_nofile }}" } + - { limit_type: '-', limit_item: 'nproc', value: "{{ sonarqube_nproc }}" } + +- name: "SONARQUBE | Set up the max files" + sysctl: + name: fs.file-max + value: "{{ sonarqube_fs_file_max }}" + state: present + reload: yes + +- name: "SONARQUBE | Set up the VM max_map_count" + sysctl: + name: vm.max_map_count + value: "{{ sonarqube_vm_max_map_count }}" + state: present + reload: yes \ No newline at end of file