diff --git a/defaults/main.yml b/defaults/main.yml index 3813926..3ead827 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -51,9 +51,12 @@ jenkins_etc_args: - "--prefix={{ jenkins_etc_prefix }}" # Jenkins cli -jenkins_base_url: "http://localhost:{{ jenkins_etc_http_port }}" +jenkins_base_url: "{{ 'http://' ~ jenkins_etc_listen_address ~ ':' + ~ jenkins_etc_http_port ~ jenkins_etc_prefix }}" jenkins_cli_download_url: "{{ jenkins_base_url }}/jnlpJars/jenkins-cli.jar" -jenkins_cli: "{{ jenkins_etc_home_location }}/jenkins-cli.jar" +jenkins_cli_path: "{{ jenkins_etc_home_location }}/jenkins-cli.jar" +jenkins_deployment_ssh_key: "{{ jenkins_etc_home_location }}/.ssh/id_rsa" +jenkins_groovy_scripts_path: "{{ jenkins_etc_home_location }}/groovy_scripts" # Jenkins waiting availability test jenkins_waiting_available_retries: 10 diff --git a/tasks/manage_cli.yml b/tasks/manage_cli.yml index a1fd6c0..d7a6d24 100644 --- a/tasks/manage_cli.yml +++ b/tasks/manage_cli.yml @@ -7,5 +7,5 @@ become_user: "{{ jenkins_etc_user }}" get_url: url: "{{ jenkins_cli_download_url }}" - dest: "{{ jenkins_cli }}" + dest: "{{ jenkins_cli_path }}" force: True diff --git a/tasks/manage_credentials.yml b/tasks/manage_credentials.yml index 31875c1..4e7441d 100644 --- a/tasks/manage_credentials.yml +++ b/tasks/manage_credentials.yml @@ -7,6 +7,10 @@ become_user: "{{ jenkins_etc_user }}" remove_jenkins_credentials: credentials_domain: "{{ item }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" with_items: "{{ jenkins_credentials_domains_to_empty }}" @@ -24,6 +28,10 @@ private_key_passphrase: "{{ item.private_key_passphrase }}" description: "{{ item.description }}" state: "{{ item.state }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_ssh_credentials' with_items: "{{ jenkins_credentials }}" diff --git a/tasks/manage_main_config.yml b/tasks/manage_main_config.yml index 4f894dc..8136c6c 100644 --- a/tasks/manage_main_config.yml +++ b/tasks/manage_main_config.yml @@ -12,6 +12,10 @@ authorization_strategy: "{{ jenkins_authorization_strategy }}" crumb_issuer: "{{ jenkins_crumb_issuer }}" use_private_key: False + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_deployment_user_without_ssh_key' ignore_errors: True @@ -35,6 +39,10 @@ security_realm: "{{ jenkins_security_realm }}" authorization_strategy: "{{ jenkins_authorization_strategy }}" crumb_issuer: "{{ jenkins_crumb_issuer }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_deployment_user' with_items: @@ -59,6 +67,10 @@ security_realm: "{{ jenkins_security_realm }}" authorization_strategy: "{{ jenkins_authorization_strategy }}" crumb_issuer: "{{ jenkins_crumb_issuer }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_users_or_security' with_items: "{{ jenkins_users }}" @@ -80,6 +92,10 @@ quiet_period: "{{ jenkins_config_quiet_period }}" scm_checkout_retry_count: "{{ jenkins_config_scm_checkout_retry_count }}" slave_agent_port: "{{ jenkins_config_slave_agent_port }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_change_main_configuration' @@ -90,6 +106,10 @@ email: "{{ jenkins_location_administrator_email }}" full_name: "{{ jenkins_location_administrator_full_name }}" jenkins_url: "{{ jenkins_location_url }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_change_administrator_email_address' when: - "{{ jenkins_location_administrator_email != '' }}" diff --git a/tasks/manage_plugins.yml b/tasks/manage_plugins.yml index 26c07e9..06b7cd9 100644 --- a/tasks/manage_plugins.yml +++ b/tasks/manage_plugins.yml @@ -18,9 +18,12 @@ register: 'jenkins_tasks_enable_plugins' enable_jenkins_plugin: name: "{{ item.name }}" - cli_path: '/var/lib/jenkins/jenkins-cli.jar' use_ssh_key: "{{ (jenkins_authentication_disabled is defined) and (jenkins_authentication_disabled | skipped) }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" with_items: "{{ jenkins_plugins }}" diff --git a/tasks/manage_plugins_config.yml b/tasks/manage_plugins_config.yml index 1d00850..4398134 100644 --- a/tasks/manage_plugins_config.yml +++ b/tasks/manage_plugins_config.yml @@ -9,6 +9,10 @@ create_accounts: "{{ jenkins_plugin_git_create_account_based_on_email }}" email: "{{ jenkins_plugin_git_global_email }}" full_name: "{{ jenkins_plugin_git_global_full_name }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_change_plugin_git' when: - "{{ 'git' in (jenkins_plugins | map(attribute='name')) }}" @@ -27,6 +31,10 @@ smtp_port: "{{ jenkins_plugin_mailer_smtp_port }}" smtp_user: "{{ jenkins_plugin_mailer_smtp_user }}" use_ssl: "{{ jenkins_plugin_mailer_use_ssl }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_plugin_mailer' when: @@ -39,6 +47,10 @@ become_user: "{{ jenkins_etc_user }}" remove_jenkins_github_servers: do_task: True + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_change_plugin_github_remove_servers' when: - "{{ 'github' in (jenkins_plugins | map(attribute='name')) }}" @@ -54,6 +66,10 @@ credentials_id: "{{ item.credentials_id }}" custom_url: "{{ item.custom_url }}" client_cache_size: "{{ item.client_cache_size }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_change_plugin_github' with_items: "{{ jenkins_plugin_github_servers }}" when: @@ -70,6 +86,10 @@ public_key: "{{ jenkins_plugin_debian_package_builder_gpg.public_key }}" private_key: "{{ jenkins_plugin_debian_package_builder_gpg.private_key }}" passphrase: "{{ jenkins_plugin_debian_package_builder_gpg.passphrase }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_plugin_debian_package_builder_gpg' when: @@ -83,6 +103,10 @@ become_user: "{{ jenkins_etc_user }}" remove_jenkins_debian_package_builder_repo: do_task: True + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_change_plugin_debian_package_builder_remove_repo' when: - "{{ jenkins_plugin_debian_package_builder_remove_repositories }}" @@ -103,6 +127,10 @@ key_path: "{{ item.key_path }}" options: "{{ item.options }}" state: "{{ item.state }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_plugin_debian_package_builder_repo' with_items: "{{ jenkins_plugin_debian_package_builder_repo }}" @@ -119,6 +147,10 @@ api_token: "{{ jenkins_plugin_gitlab_api_token }}" host_url: "{{ jenkins_plugin_gitlab_host_url }}" ignore_cert_error: "{{ jenkins_plugin_gitlab_ignore_cert_error }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_plugin_gitlab' when: @@ -135,6 +167,10 @@ v2_enabled: "{{ jenkins_plugin_hipchat_v2_enabled }}" room: "{{ jenkins_plugin_hipchat_room }}" send_as: "{{ jenkins_plugin_hipchat_send_as }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" no_log: True register: 'jenkins_change_plugin_hipchat' when: @@ -152,6 +188,10 @@ color: "{{ item.color }}" message_template: "{{ item.message_template }}" state: "{{ item.state }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_change_plugin_hipchat_notifications' with_items: "{{ jenkins_plugin_hipchat_notifications }}" when: @@ -171,6 +211,10 @@ credentials_id: "{{ item.credentials_id }}" templates: "{{ item.templates }}" state: "{{ item.state }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_change_plugin_docker_clouds' with_items: "{{ jenkins_plugin_docker_clouds }}" when: diff --git a/tasks/manage_plugins_installation.yml b/tasks/manage_plugins_installation.yml index e60b232..3b2faba 100644 --- a/tasks/manage_plugins_installation.yml +++ b/tasks/manage_plugins_installation.yml @@ -8,9 +8,12 @@ register: 'jenkins_tasks_dependencies_plugins' get_plugin_dependencies: name: "{{ item.name }}" - cli_path: '/var/lib/jenkins/jenkins-cli.jar' use_ssh_key: "{{ (jenkins_authentication_disabled is defined) and (jenkins_authentication_disabled | skipped) }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" with_items: "{{ jenkins_plugins }}" changed_when: False @@ -22,9 +25,12 @@ install_jenkins_plugin: name: "{{ item.1 }}" state: "{{ jenkins_plugins_state }}" - cli_path: '/var/lib/jenkins/jenkins-cli.jar' use_ssh_key: "{{ (jenkins_authentication_disabled is defined) and (jenkins_authentication_disabled | skipped) }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" with_subelements: - "{{ jenkins_tasks_dependencies_plugins.results }}" - 'output' diff --git a/tasks/manage_plugins_upgrade.yml b/tasks/manage_plugins_upgrade.yml index 5073aa4..0cc30e7 100644 --- a/tasks/manage_plugins_upgrade.yml +++ b/tasks/manage_plugins_upgrade.yml @@ -6,9 +6,12 @@ become: True become_user: "{{ jenkins_etc_user }}" get_jenkins_plugins: - cli_path: '/var/lib/jenkins/jenkins-cli.jar' use_ssh_key: "{{ (jenkins_authentication_disabled is defined) and (jenkins_authentication_disabled | skipped) }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" register: 'jenkins_list_plugins_for_upgrade' changed_when: False @@ -19,10 +22,13 @@ register: 'jenkins_tasks_upgrade_plugins' install_jenkins_plugin: name: "{{ item }}" - cli_path: '/var/lib/jenkins/jenkins-cli.jar' state: 'latest' use_ssh_key: "{{ (jenkins_authentication_disabled is defined) and (jenkins_authentication_disabled | skipped) }}" + cli_path: "{{ jenkins_cli_path }}" + deployment_ssh_key: "{{ jenkins_deployment_ssh_key }}" + groovy_scripts_path: "{{ jenkins_groovy_scripts_path }}" + url: "{{ jenkins_base_url }}" with_items: "{{ jenkins_list_plugins_for_upgrade.has_update }}" diff --git a/tests/common_tests.yml b/tests/common_tests.yml index 19de82a..30a3c3d 100644 --- a/tests/common_tests.yml +++ b/tests/common_tests.yml @@ -30,7 +30,7 @@ register: 'jenkins_list_plugins_test' shell: > java - -jar {{ jenkins_cli }} + -jar {{ jenkins_cli_path }} -s {{ jenkins_base_url }} list-plugins | awk '{ print $1 }' @@ -56,7 +56,7 @@ register: 'jenkins_list_plugins_with_upgrade_test' shell: > java - -jar {{ jenkins_cli }} + -jar {{ jenkins_cli_path }} -s {{ jenkins_base_url }} list-plugins | grep ')$'