Hello! Thanks for packer.
Prepare:
sudo apt update
sudo apt install git jq python3-pip -y
sudo pip3 install ansible pywinrm
ansible-galaxy collection install ansible.windows
ansible-galaxy install justin_p.pdc
Install latest packer version
Usially ansible have output
❯ ansible-playbook -i ansible/inventory ansible/packer_active_directory.yml
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC
8.4.0]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
PLAY [all] ****************************************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [windows.local]
TASK [justin_p.pdc : Assert mandatory variables have been set] ************************************************************************************************************
ok: [windows.local] => (item=pdc_administrator_username) => changed=false
ansible_loop_var: item
item: pdc_administrator_username
msg: All assertions passed
ok: [windows.local] => (item=pdc_administrator_password) => changed=false
ansible_loop_var: item
item: pdc_administrator_password
msg: All assertions passed
ok: [windows.local] => (item=ansible_windows_domain_member) => changed=false
ansible_loop_var: item
item: ansible_windows_domain_member
msg: All assertions passed
ok: [windows.local] => (item=pdc_dns_nics) => changed=false
ansible_loop_var: item
item: pdc_dns_nics
msg: All assertions passed
ok: [windows.local] => (item=pdc_dns_servers) => changed=false
ansible_loop_var: item
item: pdc_dns_servers
msg: All assertions passed
ok: [windows.local] => (item=pdc_domain) => changed=false
ansible_loop_var: item
item: pdc_domain
msg: All assertions passed
ok: [windows.local] => (item=pdc_netbios) => changed=false
ansible_loop_var: item
item: pdc_netbios
msg: All assertions passed
ok: [windows.local] => (item=pdc_domain_safe_mode_password) => changed=false
ansible_loop_var: item
item: pdc_domain_safe_mode_password
msg: All assertions passed
ok: [windows.local] => (item=pdc_domain_functional_level) => changed=false
ansible_loop_var: item
item: pdc_domain_functional_level
msg: All assertions passed
ok: [windows.local] => (item=pdc_forest_functional_level) => changed=false
ansible_loop_var: item
item: pdc_forest_functional_level
msg: All assertions passed
ok: [windows.local] => (item=pdc_delayed_services) => changed=false
ansible_loop_var: item
item: pdc_delayed_services
msg: All assertions passed
ok: [windows.local] => (item=pdc_required_psmodules) => changed=false
ansible_loop_var: item
item: pdc_required_psmodules
msg: All assertions passed
ok: [windows.local] => (item=pdc_required_features) => changed=false
ansible_loop_var: item
item: pdc_required_features
msg: All assertions passed
I try to get same ansible output when user packer provisioner.
But i dont this output another.
Packer output
==> yandex: Provisioning with Ansible...
yandex: Not using Proxy adapter for Ansible run:
yandex: Using WinRM Password from Packer communicator...
==> yandex: Executing Ansible: ansible-playbook -e packer_build_name="yandex" -e packer_builder_type=yandex -vvvv --tags install --extra-vars ansible_port=5986 ansible_connection=winrm ansible_winrm_transport=basic ansible_user=Administrator ansible_password=***** ansible_winrm_server_cert_validation=ignore -e ansible_password=***** -i /tmp/packer-provisioner-ansible980912150 /home/apatsev/packer-ansible-active-directory-yandex-cloud/ansible/packer_active_directory.yml
yandex: ansible-playbook [core 2.11.4]
yandex: config file = /home/apatsev/packer-ansible-active-directory-yandex-cloud/ansible.cfg
yandex: configured module search path = ['/home/apatsev/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
yandex: ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
yandex: ansible collection location = /home/apatsev/.ansible/collections:/usr/share/ansible/collections
yandex: executable location = /usr/local/bin/ansible-playbook
yandex: python version = 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0]
yandex: jinja version = 2.10.1
yandex: libyaml = True
yandex: Using /home/apatsev/packer-ansible-active-directory-yandex-cloud/ansible.cfg as config file
yandex: setting up inventory plugins
yandex: host_list declined parsing /tmp/packer-provisioner-ansible980912150 as it did not pass its verify_file() method
yandex: script declined parsing /tmp/packer-provisioner-ansible980912150 as it did not pass its verify_file() method
yandex: auto declined parsing /tmp/packer-provisioner-ansible980912150 as it did not pass its verify_file() method
yandex: Parsed /tmp/packer-provisioner-ansible980912150 inventory source with ini plugin
yandex: redirecting (type: modules) ansible.builtin.win_user to ansible.windows.win_user
yandex: Loading collection ansible.windows from /home/apatsev/.ansible/collections/ansible_collections/ansible/windows
yandex: redirecting (type: modules) ansible.builtin.win_feature to ansible.windows.win_feature
yandex: redirecting (type: modules) ansible.builtin.win_domain to ansible.windows.win_domain
yandex: redirecting (type: modules) ansible.builtin.win_dsc to ansible.windows.win_dsc
yandex: redirecting (type: modules) ansible.builtin.win_shell to ansible.windows.win_shell
yandex: redirecting (type: modules) ansible.builtin.win_dns_client to ansible.windows.win_dns_client
yandex: redirecting (type: modules) ansible.builtin.win_domain_user to community.windows.win_domain_user
yandex: Loading collection community.windows from /usr/local/lib/python3.8/dist-packages/ansible_collections/community/windows
yandex: redirecting (type: action) ansible.builtin.win_reboot to ansible.windows.win_reboot
yandex: redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
yandex: Loading collection community.general from /usr/local/lib/python3.8/dist-packages/ansible_collections/community/general
yandex: redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
yandex: Loading callback plugin community.general.yaml of type stdout, v2.0 from /usr/local/lib/python3.8/dist-packages/ansible_collections/community/general/plugins/callback/yaml.py
yandex: Skipping callback 'default', as we already have a stdout callback.
yandex: Skipping callback 'minimal', as we already have a stdout callback.
yandex: Skipping callback 'oneline', as we already have a stdout callback.
yandex:
yandex: PLAYBOOK: packer_active_directory.yml ******************************************
yandex: Positional arguments: /home/apatsev/packer-ansible-active-directory-yandex-cloud/ansible/packer_active_directory.yml
yandex: verbosity: 4
yandex: connection: smart
yandex: timeout: 10
yandex: become_method: sudo
yandex: tags: ('install',)
yandex: inventory: ('/tmp/packer-provisioner-ansible980912150',)
yandex: extra_vars: ('packer_build_name="yandex"', 'packer_builder_type=yandex', 'ansible_port=5986 ansible_connection=winrm ansible_winrm_transport=basic ansible_user=Administrator ansible_password=xxxxxxxxxx ansible_winrm_server_cert_validation=ignore', 'ansible_password=xxxxxxxx')
yandex: forks: 5
yandex: 1 plays in /home/apatsev/packer-ansible-active-directory-yandex-cloud/ansible/packer_active_directory.yml
yandex:
yandex: PLAY [all] *********************************************************************
yandex:
yandex: TASK [Gathering Facts] *********************************************************
yandex: task path: /home/apatsev/packer-ansible-active-directory-yandex-cloud/ansible/packer_active_directory.yml:1
yandex: redirecting (type: modules) ansible.builtin.setup to ansible.windows.setup
yandex: Using module file /home/apatsev/.ansible/collections/ansible_collections/ansible/windows/plugins/modules/setup.ps1
yandex: Pipelining is enabled.
yandex: <84.201.129.186> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 84.201.129.186
yandex: EXEC (via pipeline wrapper)
yandex: ok: [default]
yandex: META: ran handlers
yandex: META:
yandex: META: ran handlers
yandex: META: ran handlers
yandex:
yandex: PLAY RECAP *********************************************************************
yandex: default : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
I have ansible.cfg in root directory.
Whern run ansible in packer used ansible.cfg
==> yandex: Executing Ansible: ansible-playbook -e packer_build_name="yandex" -e packer_builder_type=yandex -vvvv --tags install --extra-vars ansible_port=5986 ansible_connection=winrm ansible_winrm_transport=basic ansible_user=Administrator ansible_password=***** ansible_winrm_server_cert_validation=ignore -e ansible_password=***** -i /tmp/packer-provisioner-ansible318540280 /home/apatsev/packer-ansible-active-directory-yandex-cloud/ansible/packer_active_directory.yml
yandex: ansible-playbook [core 2.11.4]
yandex: config file = /home/apatsev/packer-ansible-active-directory-yandex-cloud/ansible.cfg
Ansible.cfg:
[defaults]
# Human-readable output
stdout_callback = yaml
# Disabling Host key checking
host_key_checking = False
# Disable validate certs
validate_certs=false
Config:
{
"type": "ansible",
"use_proxy": false,
"playbook_file": "{{template_dir}}/ansible/packer_active_directory.yml",
"extra_arguments": [
"--tags",
"install",
"--extra-vars", "ansible_port=5986 ansible_connection=winrm ansible_winrm_transport=basic ansible_user=Administrator ansible_password={{user `password`}} ansible_winrm_server_cert_validation=ignore"
]
},
Full config