lean_delivery.sonarqube

SonarQube 役割

ライセンス Galaxy Ansible Ansible

この役割は、拡張されたプラグインセットを持つSonarQubeをインストールします。以下のプレイブック例では、openJDK、PostgreSQLデータベース、およびhttpsが有効なnginxウェブサーバーも使用しています。

この記事を参照してください: https://lean-delivery.com/2020/02/how-to-add-sonarqube-to-ci-process.html

デフォルトのプラグインに加えて、SonarQube役割は次の推奨プラグインもインストールできます:

  • checkstyle-sonar-plugin
  • sonar-pmd-plugin
  • sonar-findbugs-plugin
  • mutation-analysis-plugin
  • sonar-jdepend-plugin
  • sonar-jproperties-plugin
  • sonar-groovy-plugin
  • sonar-dependency-check-plugin
  • sonar-json-plugin
  • sonar-yaml-plugin
  • sonar-ansible-plugin
  • sonar-shellcheck-plugin

また、オプションのプラグインもインストールできます。注意してください、いくつかは最新のSonarQubeバージョンでサポートされていない場合があります:

  • qualinsight-sonarqube-smell-plugin
  • qualinsight-sonarqube-badges
  • sonar-auth-github-plugin
  • sonar-auth-bitbucket-plugin
  • sonar-bitbucket-plugin (Bitbucket Cloud用)
  • sonar-stash-plugin (Bitbucket Server用)
  • sonar-auth-gitlab-plugin
  • sonar-gitlab-plugin
  • sonar-xanitizer-plugin
  • sonar-build-breaker-plugin
  • sonar-issueresolver-plugin
  • sonarqube-community-branch-plugin
  • sonar-aemrules-plugin

プラグインのマトリックスはここにあります: https://docs.sonarsource.com/sonarqube/latest/instance-administration/plugin-version-matrix/

この役割は、いくつかの設定オプションも提供します:

  • SonarQubeを新しいバージョンに更新するときにデータベースを移行する機能
  • Jenkins webhookを設定する機能
  • カスタムプロファイルを復元する機能
  • LDAP設定
  • 管理者ユーザーのパスワードを変更する機能

Jenkinsパイプラインの例はここにあります: https://raw.githubusercontent.com/lean-delivery/ansible-role-sonarqube/master/files/example_pipeline.groovy

要件

  • サポートされるAnsibleバージョン
    • 5 (2.12) - テストにはまだ含まれていませんが、動作するはずです
    • 6 (2.13)
    • 7 (2.14)
  • サポートされるSonarQubeバージョン
    • 7.9.6 (前のLTS)
    • 8.9.10 (前のLTS)
    • 9.9.6 LTS
    • 10.0 - 10.6
  • サポートされるJavaバージョン
    • 11
    • 17(SonarQube 9.9以上に使用)
  • サポートされるデータベース
    • PostgreSQL
    • MySQL(推奨されません)
    • 埋め込みH2(テスト用のみ)
  • サポートされるウェブサーバー(httpsのリバースプロキシ)
    • nginx
  • サポートされるOS
    • CentOS、RHEL
      • 7
    • Ubuntu
      • 18.04
      • 20.04 - テストにはまだ含まれていませんが、動作するはずです
      • 22.04 - テストにはまだ含まれていませんが、動作するはずです

Java、データベース、自己署名証明書付きのウェブサーバーは前もってインストールする必要があります。次のGalaxyの役割を使用してください:

  • lean_delivery.java
  • geerlingguy.postgresql
  • jdauphant.ssl-certs
  • nginxinc.nginx

役割変数

  • sonar_version - SonarQubeバージョン
  • sonar_path - インストールディレクトリ
    デフォルト: /opt/sonarqube
  • sonar_user - SonarQubeをインストールするユーザー
    デフォルト: sonar
  • sonar_group - SonarQubeユーザーのグループ
    デフォルト: sonar
  • sonar_nofile - SonarQubeを実行するユーザーが開けるファイルディスクリプタの数
    デフォルト: 65536
  • sonar_nproc - SonarQubeを実行するユーザーが開けるスレッドの数
    デフォルト: 4096
  • sonar_max_map_count - Elasticsearchに必要なmmapカウントの制限
    デフォルト: 262144
  • sonar_log_level - SonarQubeサーバーのログレベル
    デフォルト: INFO
  • sonar_java_opts:
    • web - SonarQubeのウェブ部分の追加Javaオプション
      デフォルト: -Xmx512m -Xms128m
    • es - Elasticsearchの追加Javaオプション
      デフォルト: -Xms512m -Xmx512m
    • ce - コンピュートエンジンの追加Javaオプション
      デフォルト: -Xmx512m -Xms128m
  • web:
    • host - SonarQubeのバインドIPアドレス
      デフォルト: 0.0.0.0
    • port - HTTP接続のためのTCPポート
      デフォルト: 9000
    • path - ウェブコンテキスト
      デフォルト: /
  • sonar_db - データベース設定
    • type
      デフォルト : postgresql
    • port
      デフォルト : 5432
    • host
      デフォルト : localhost
    • name
      デフォルト: sonar
    • user
      デフォルト: sonar
    • password
      デフォルト: sonar
    • options
      デフォルト:
  • sonar_store - SonarQubeアーティファクトプロバイダー
    デフォルト: https://sonarsource.bintray.com/Distribution/sonarqube
  • sonar_check_url - SonarQubeの起動確認用URL
    デフォルト: http://{{ web.host }}:{{ web.port }}
  • sonar_download - sonarqube.zipのダウンロードが必要かどうか。ダウンロードできない場合はfalseに設定し、プレイブック実行前に手動でzipをsonar_download_pathに配置します。 デフォルト: true
  • sonar_download_path - ローカルダウンロードパス
    デフォルト: /tmp/
  • sonar_proxy_type - ウェブサーバー、現在はnginxのみがサポートされています
    デフォルト: nginx
  • sonar_proxy_server_name - ウェブサーバー設定でのサーバー名
    デフォルト: '{{ ansible_fqdn }}'
  • sonar_proxy_http - HTTP接続が許可されるか
    デフォルト: false
  • sonar_proxy_http_port - HTTPポート
    デフォルト: 80
  • sonar_proxy_ssl - HTTPS接続が許可されるか
    デフォルト: true
  • sonar_proxy_ssl_port - HTTPSポート
    デフォルト: 443
  • sonar_proxy_ssl_cert_path - 証明書のパス
    デフォルト: '/etc/ssl/{{ sonar_proxy_server_name }}/{{ sonar_proxy_server_name }}.pem'
  • sonar_proxy_ssl_key_path - キーのパス
    デフォルト: '/etc/ssl/{{ sonar_proxy_server_name }}/{{ sonar_proxy_server_name }}.key'
  • sonar_proxy_client_max_body_size - ウェブサーバー設定のクライアント最大ボディサイズ
    デフォルト: 32m
  • sonar_install_recommended_plugins - 推奨プラグインが必要か
    デフォルト: true
  • sonar_recommended_plugins - 推奨プラグインのリスト\
  • sonar_update_default_plugins - デフォルトプラグインの更新が必要か
    デフォルト: true
  • sonar_default_plugins - デフォルトプラグインのリスト\
  • sonar_install_optional_plugins - オプションのプラグインが必要か
    デフォルト: false
  • sonar_optional_plugins - デフォルトでオフになっているオプションのプラグインのリスト。すべてが最新のSonarQubeバージョンでサポートされているわけではないため、必要なものを選択してこのプロパティをオーバーライドしてください。
  • sonar_excluded_plugins - SonarQubeインストーラーから除外された古いプラグインのリスト
  • sonar_default_excluded_plugins - 不要なデフォルトプラグインのリスト
    デフォルト: []
  • sonar_web_user - 管理者ユーザーのユーザー名
    デフォルト: admin
  • sonar_web_password - 管理者ユーザーのパスワード
    デフォルト: admin
  • change_password - パスワードを変更するためにtrueに設定
    デフォルト: false
  • sonar_web_old_password - 現在のパスワード(変更前)
    デフォルト: admin
  • sonar_migrate_db - データベースの移行が必要か。既存のSonarQubeを新しいバージョンに更新する場合はtrueに設定してください。
    デフォルト: false
  • sonar_set_jenkins_webhook - Jenkins webhookの設定が必要か
    デフォルト: false
  • sonar_jenkins_webhook_name - Jenkins webhookの名前
    デフォルト: jenkins
  • sonar_jenkins_webhook_url - Jenkins webhookのURL
    デフォルト: https://jenkins.example.com/sonarqube-webhook/
  • sonar_restore_profiles - プロファイルの復元が必要か
    デフォルト: false
  • sonar_profile_list - 復元するプロファイルのリスト
  • sonar_updatecenter_activate - SonarQubeアップデートセンターを有効化
    デフォルト: true

LDAP設定セクション。 説明については https://docs.sonarqube.org/latest/instance-administration/delegated-auth/#header-6 を参照してください。

  • ldap:
    デフォルト: 未定義
    • authenticator_downcase
      デフォルト: false
    • url
      デフォルト: ldap://myserver.mycompany.com
    • bind_dn
      デフォルト: my_bind_dn
    • bind_password
      デフォルト: my_bind_password
    • authentication
      デフォルト: simple
    • realm
      デフォルト:
    • contextFactoryClass
      デフォルト: com.sun.jndi.ldap.LdapCtxFactory
    • StartTLS
      デフォルト: false
    • followReferrals
      デフォルト: true
    • user_base_dn
      デフォルト : ou=Users,dc=mycompany,dc=com
    • user_request
      デフォルト: (&(objectClass=inetOrgPerson)(uid={login}))
    • user_real_name_attribute
      デフォルト: cn
    • user_email_attribute
      デフォルト: mail
    • group_base_dn
      デフォルト: ou=Groups,dc=sonarsource,dc=com
    • group_request
      デフォルト: (&(objectClass=posixGroup)(memberUid={uid}))
    • group_idAttribute
      デフォルト: cn

プレイブックの例

---
- name: SonarQubeをインストール
  hosts: sonarqube
  become: true
  vars:
    # java
    java_major_version: 17
    transport: repositories
    # postgresql
    postgresql_users:
      - name: sonar
        password: sonar
    postgresql_databases:
      - name: sonar
    # ssl-certs
    ssl_certs_path_owner: nginx
    ssl_certs_path_group: nginx
    ssl_certs_common_name: sonarqube.example.com
    # sonarqube
    sonar_version: 10.6.0.92116
    sonar_check_url: 'http://{{ ansible_fqdn }}:9000'
    sonar_proxy_server_name: sonarqube.example.com
    sonar_install_optional_plugins: true
    sonar_optional_plugins: 
      - 'https://github.com/adnovum/sonar-build-breaker/releases/download/{{ build_breaker_epversion }}'
    sonar_default_excluded_plugins:
      - '{{ sonar_plugins_path }}/sonar-flex-plugin-2.12.0.4568.jar'
    sonar_web_password: your_new_secure_password
    change_password: true
    sonar_web_old_password: admin
    sonar_migrate_db: false  # SonarQubeを新しいバージョンに更新する場合はtrueに設定
    sonar_set_jenkins_webhook: true
    sonar_jenkins_webhook_url: https://jenkins.example.com/sonarqube-webhook/
    sonar_restore_profiles: true
    sonar_profile_list:
      - files/example_profile.xml
  pre_tasks:
    - name: rpmキーをインストール
      rpm_key:
        state: present
        key: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}
      when: ansible_distribution == 'RedHat'
    - name: epelをインストール
      package:
        name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
        state: present
      when: ansible_distribution == 'RedHat'
    # プラグインの競合を防ぐために以前にインストールされたsonarを削除
    - name: sonarを削除
      file:
        path: '{{ sonar_path }}'
        state: absent
  roles:
    - role: lean_delivery.java
    - role: geerlingguy.postgresql
    - role: nginxinc.nginx
    - role: jdauphant.ssl-certs
    - role: lean_delivery.sonarqube
  tasks:
    - name: デフォルトのnginx設定を削除
      file:
        path: /etc/nginx/conf.d/default.conf
        state: absent
    - name: nginxを再読み込み
      command: 'nginx -s reload'

ライセンス

Apache

著者情報

著者:

プロジェクトについて

Lean Delivery SonarQube server install

インストール
ansible-galaxy install lean_delivery.sonarqube
ライセンス
apache-2.0
ダウンロード
25.1k
所有者
Simplify by using!