Tag: DevOps

  • Visual Studio Code Could Not Resolve Python Interpreter Path

    The following warning appears when Visual Studio Code (VS Code) connects to a Python project on a remote server, and the virtual environment does not launch automatically:

    Default interpreter path /opt/homebrew/bin/python3 could not be resolved: Could not resolve interpreter path /opt/homebrew/bin/python3

    This problem can occur when Homebrew installs VS Code in a way that misconfigures the default interpreter path.

    What the error means

    VS Code is trying to use a Python interpreter path that it cannot resolve on the remote machine. This often happens because the path points to a local‑only Homebrew location (such as /opt/homebrew/bin/python3) that does not exist or is not accessible on the remote server.

    How to fix it

    1. Open Settings in VS Code (use Cmd + , on macOS or Ctrl + , on Windows/Linux).
    2. Select the Remote tab (or search for “remote” settings).
    3. Search for python.defaultInterpreterPath and remove its value.
    4. Search for python-envs.defaultEnvManager and remove its value.
    5. Close and reopen the VS Code window connected to the remote server.

    After reopening, VS Code should no longer show the “could not resolve interpreter path” warning and will rely on the correct Python interpreter or virtual environment available on the remote machine.

  • Homebrew Installed Jenkins on MacOS Sequoia Cannot be Accessed From External

    I recently installed Jenkins 2.479.2 on MacOS Sequoia (15.1). The service is working fine on http://localhost:8080, but it can not be accessed from any other devices at my home.

    This post provided solutions to fix that issue. Here is a summary:

    1. Make sure the MacOS firewall is disabled, or the port is enabled on the firewall.
    2. Replace 127.0.0.1 with 0.0.0.0 in the file /opt/homebrew/opt/jenkins-lts/homebrew.mxcl.jenkins-lts.plist.
    3. Restart the Jenkins service with brew services restart jenkins-lts.
      • You can use the command to restart other brew installed services. Use brew services info --all to list all available services.

  • What is the time format in Bitbucket API?

    I was trying to retrieve a report in a Bitbucket instance. The return from the API contains event dates. However, the value looks strange. It is something like 1680143775227.

    The format looks like Unix Epoch Timestamp. But it was converted to a far future time in any online converters.

    The .Net action [System.DateTime]::UnixEpoch.AddSeconds() threw an error:

    MethodInvocationException: Exception calling "AddSeconds" with "1" argument(s): "Value to add was out of range. (Parameter 'value')"

    The solution is using [System.DateTime]::UnixEpoch.AddMilliSeconds() to convert the time.

    Such format calls Epoch Milliseconds or Unix Time in Milliseconds.

  • Move Terraform Providers to Other Folders

    Create a new control file with the name .terraformrc or terraform.rc in your profile folder.

    Add the following lines:

    plugin_cache_dir   = "$HOME/.terraform.d/plugin-cache"

    Create the folder .terraform.d/plugin-cache in your profile folder.

    The providers will be downloaded to the cache folder when you run terraform init.


    If you don’t want to create the control file in the profile folder. Alternative is to create an environment variable.

    export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache"
    
  • Setup Terraform and Ansible for Windows provisionon CentOS

    Setup Terraform and Ansible for Windows provisionon CentOS

    Provisioning Windows machines with Terraform is easy. Configuring Windows machines with Ansible is also not complex. However, it’s a little bit challenging to combine them. The following steps are some ideas about handling a Windows machine from provisioning to post configuration without modifying the winrm configuration on the guest operating system.

    1. Install required repos for yum.
    yum -y install https://repo.ius.io/ius-release-el7.rpm
    yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
    yum -y install epel-release
    yum -y install yum-utils
    yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
    ShellScript
    1. Install Terraform.
    sudo yum -y install terraform
    ShellScript
    1. Install Ansible.
    sudo yum -y install ansible
    ShellScript
    1. Install Kerberos.
    yum -y install gcc python-devel krb5-devel krb5-libs krb5-workstation
    ShellScript
    1. Install pip.
    sudo yum -y install python-pip
    
    # You probably need the following packages if you are using VPN
    pip install pysocks
    ShellScript
    1. Install pywinrm[kerberos].
    pip install pywinrm[kerberos]
    ShellScript
    1. Configure /etc/krb5.conf.
      The following are the required lines. Please make sure to change the domain name to yours. And it’s case-sensitive.
    [libdefaults]
     dns_lookup_realm = true
     dns_lookup_kdc = true
     forward = true
     forwardable = true
     default_realm = ZHENGWU.ORG
    
    
    [realms]
     ZHENGWU.ORG = {
      kdc = DC.ZHENGWU.ORG
      admin_server = DC.ZHENGWU.ORG
     }
    
    [domain_realm]
     .zhengwu.org = ZHENGWU.ORG
     zhengwu.org = ZHENGWU.ORG
    ShellScript
    1. Create an Ansible inventory file.
    [win] #Group name
    dc.zhengwu.org #This is the target server list
     
    
    [win:vars]
    ansible_connection=winrm 
    
    ansible_user=administrator #It's better a domain admin account.
    ansible_password=P@ssw0rd #Change this password
    ansible_port=5985
    ansible_winrm_transport=kerberos
    ansible_winrm_server_cert_validation=ignore
    ShellScript
    1. Run Ansible win_ping test.
    ansible <group in inventory file> -m win_ping -i <inventory file>
    ShellScript
  • Packer Naming Conflicts with Linux Native Command

    Packer Naming Conflicts with Linux Native Command

    HashiCorp Packer is a standalone tool for image management across multi-cloud providers. The installation is simple. But you may experience packer command naming conflicts if the OS is Red Hat or CentOS.

    For example, run following command and see nothing returned back on the screen.

    packer

    And if you hit ‘Enter’ key. The return is:

    skipping line: 1
    skipping line: 2
    skipping line: 3
    skipping line: 4
    skipping line: 5
    skipping line: 6
    skipping line: 7

    If you see same behavior on the machine. Certainly you are experiencing the same issue here.

    The reason is the packer naming conflicts with the Red Hat / CentOS native module cracklib. Some articles on the internet say delete the native packer command. However, I think that’s not an ideal option. Because the module is used to generate a random password and check the password complex level.

    The alternative I’m using is rename my HashiCorp Packer command.

    Firstly, you need to rename the HashiCorp Packer command:

    mv packer packer.io

    Secondary, specific the HashiCorp Packer path in the environment variables. I assume the HashiCorp Packer is installed under /packer/ directory.

    cd /etc/
    echo 'PATH="$PATH:~/packer/"' >> .bash_profile
    source .bash_profile

    The drawback is you have to use the renamed command packer.io instead of packer for HashiCorp Packer.

    Following are some references about cracklib.

    How To Check Password Strength In Linux With Cracklib?

    cracklib2 – utilities

    Update 05/21/2021: HashiCorp document also mentioned this issue. Thanks, Abe! 🙂