ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Using Ansible to Manage install and update Apple OSX DHCP clients

    IT Discussion
    osx ansible homebrew apple automation
    5
    100
    7.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403 @black3dynamite
      last edited by

      @black3dynamite didn't fix it.

      1 Reply Last reply Reply Quote 0
      • DustinB3403D
        DustinB3403
        last edited by

        So I know this will likely light a flame for someone, but when in the hell is yaml so annoying?

        @IRJ how do I check my yaml configuration using the software you recommended, both VSCode and the extension are installed - just not sure how the heck to use yet.

        IRJI 1 Reply Last reply Reply Quote 0
        • DustinB3403D
          DustinB3403
          last edited by

          Okay so in using the test.yaml file buried within the geerlingguy folder I was able to at least get some progress.

          ansible-playbook -i hosts apple.yml
          
          PLAY [x.x.x.143] ***********************************************************************************************************************************************************************************************************************
          
          TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
          ok: [x.x.x.143]
          
          PLAY RECAP **********************************************************************************************************************************************************************************************************************************
          x.x.x.143             : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
          

          But doesn't seem to install based on what's in the apple.yml file

          ---
          - hosts: 1x.x.x.143
            vars:
          	homebrew_clear_cache: true
          	homebrew_installed_packages:
          	  - ssh-copy-id  # from homebrew/core
          	  - nginx-full  # from dengi/nginx
          	homebrew_cask_apps:
          	  - 1Password # from hombrew/cask
          
          IRJI 1 Reply Last reply Reply Quote 0
          • IRJI
            IRJ @DustinB3403
            last edited by

            @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

            Okay so in using the test.yaml file buried within the geerlingguy folder I was able to at least get some progress.

            ansible-playbook -i hosts apple.yml

            PLAY [x.x.x.143] ***********************************************************************************************************************************************************************************************************************

            TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
            ok: [x.x.x.143]

            PLAY RECAP **********************************************************************************************************************************************************************************************************************************
            x.x.x.143 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

            But doesn't seem to install based on what's in the apple.yml file


            • hosts: 1x.x.x.143
              vars:
              homebrew_clear_cache: true
              homebrew_installed_packages:
              - ssh-copy-id # from homebrew/core
              - nginx-full # from dengi/nginx
              homebrew_cask_apps:
              - 1Password # from hombrew/cask

            Oh! I thought you were only using a single file.

            Ok let's back up. can you show the folder structure of geerlingguy folder?

            DustinB3403D 1 Reply Last reply Reply Quote 0
            • IRJI
              IRJ @DustinB3403
              last edited by IRJ

              @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

              So I know this will likely light a flame for someone, but when in the hell is yaml so annoying?

              @IRJ how do I check my yaml configuration using the software you recommended, both VSCode and the extension are installed - just not sure how the heck to use yet.

              It shows you when there is a formatting error

              No error
              8c0469e6-072d-4be0-b8d4-7a58e784f528-image.png

              Error. File lights up red and gives you a tip on how to fix.

              a8a48982-24ad-40e9-a794-cdaf1bd2c2a8-image.png

              1 Reply Last reply Reply Quote 0
              • DustinB3403D
                DustinB3403 @IRJ
                last edited by

                @IRJ said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                Okay so in using the test.yaml file buried within the geerlingguy folder I was able to at least get some progress.

                ansible-playbook -i hosts apple.yml
                
                PLAY [x.x.x.143] ***********************************************************************************************************************************************************************************************************************
                
                TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
                ok: [x.x.x.143]
                
                PLAY RECAP **********************************************************************************************************************************************************************************************************************************
                x.x.x.143             : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
                

                But doesn't seem to install based on what's in the apple.yml file

                ---
                - hosts: 1x.x.x.143
                vars:
                  homebrew_clear_cache: true
                  homebrew_installed_packages:
                    - ssh-copy-id  # from homebrew/core
                    - nginx-full  # from dengi/nginx
                  homebrew_cask_apps:
                    - 1Password # from hombrew/cask
                

                Oh! I thought you were only using a single file.

                Ok let's back up. can you show the folder structure of geerlingguy folder?

                To summarize, everything is installed in the default locations.

                tree /etc/ansible/
                /etc/ansible/
                ├── ansible.cfg
                ├── apple.yml
                ├── clients
                ├── hosts
                ├── requirements.yml
                ├── roles
                │   └── geerlingguy.homebrew
                │       ├── defaults
                │       │   └── main.yml
                │       ├── handlers
                │       │   └── main.yml
                │       ├── LICENSE
                │       ├── meta
                │       │   └── main.yml
                │       ├── README.md
                │       ├── requirements.yml
                │       ├── tasks
                │       │   ├── main.yml
                │       │   └── playbook.yml
                │       └── tests
                │           ├── local-testing
                │           │   ├── playbook.yml
                │           │   └── README.md
                │           └── test.yml
                └── ssh.sh
                
                8 directories, 17 files
                
                1 Reply Last reply Reply Quote 0
                • DustinB3403D
                  DustinB3403
                  last edited by

                  The clients file and ssh.sh are for a quick deployment of the ssh key to all of my workstations if this works out :-).

                  But ignore them for now.

                  1 Reply Last reply Reply Quote 0
                  • DustinB3403D
                    DustinB3403
                    last edited by

                    This is the updated apply.yml file

                    ---
                    - hosts: apple_workstations
                      vars:
                    	homebrew_repo: https://github.com/Homebrew/brew
                    	homebrew_prefix: /usr/local
                    	homebrew_install_path: "{{ homebrew_prefix }}/Homebrew"
                    	homebrew_bin_path: /usr/local/bin
                    	homebrew_clear_cache: true
                    	homebrew_installed_packages:
                    	  - ssh-copy-id  # from homebrew/core
                    	  - nginx-full  # from dengi/nginx
                    	homebrew_cask_apps:
                    	  - 1password
                    	homebrew_taps:
                    	  - homebrew/cask
                    	  - { name: denji/nginx, url: 'https://github.com/denji/homebrew-nginx.git' }
                    	homebrew_cask_accept_external_apps: true
                    	homebrew_cask_appdir: /Applications
                    

                    It runs without issue, but doesn't actually install 1password

                    1 Reply Last reply Reply Quote 0
                    • IRJI
                      IRJ @IRJ
                      last edited by

                      @IRJ said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                      Ok let's try this. Is your playbook only one file?

                      #***********************************************************
                      # Create or append ansible requirements file
                      #***********************************************************
                      
                      
                      sudo sh -c "echo '- src: /etc/ansible/roles/geerlineguy' >> /etc/ansible/requirements.yml"
                      
                      #***********************************************************
                      # Install the role
                      #***********************************************************
                      
                      cd /etc/ansible/
                      sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml
                      
                      #***********************************************************
                      # Run ansible playbook file
                      #***********************************************************
                      
                      sudo ansible-playbook /etc/ansible/apple.yml
                      

                      Updated. try this

                      DustinB3403D 1 Reply Last reply Reply Quote 0
                      • DustinB3403D
                        DustinB3403 @IRJ
                        last edited by

                        @IRJ Each command individually?

                        IRJI 1 Reply Last reply Reply Quote 0
                        • IRJI
                          IRJ @DustinB3403
                          last edited by

                          @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                          @IRJ Each command individually?

                          yes reinstall the role this way

                          DustinB3403D 1 Reply Last reply Reply Quote 0
                          • DustinB3403D
                            DustinB3403 @IRJ
                            last edited by

                            @IRJ So wouldn't I have to delete the role first?

                            IRJI 1 Reply Last reply Reply Quote 0
                            • DustinB3403D
                              DustinB3403
                              last edited by

                              Also this fails.

                              sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml
                               [WARNING]: - /etc/ansible/apple.yml was NOT installed successfully: the file downloaded was not a tar.gz
                              
                              ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
                              
                              IRJI 1 Reply Last reply Reply Quote 0
                              • IRJI
                                IRJ @DustinB3403
                                last edited by

                                @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                @IRJ So wouldn't I have to delete the role first?

                                Just try running it first. If you delete the role, then the reference to source file will break.

                                1 Reply Last reply Reply Quote 0
                                • IRJI
                                  IRJ @DustinB3403
                                  last edited by

                                  @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                  Also this fails.

                                  sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml
                                  [WARNING]: - /etc/ansible/apple.yml was NOT installed successfully: the file downloaded was not a tar.gz

                                  ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

                                  let me see your /etc/ansible/requirements.yml

                                  1 Reply Last reply Reply Quote 0
                                  • DustinB3403D
                                    DustinB3403
                                    last edited by

                                    cat /etc/ansible/requirements.yml
                                    - src: /etc/ansible/apple.yml
                                    - src: /etc/ansible/apple.yml
                                    - src: /etc/ansible/roles/geerlineguy
                                    
                                    IRJI 1 Reply Last reply Reply Quote 0
                                    • IRJI
                                      IRJ @DustinB3403
                                      last edited by

                                      @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                      cat /etc/ansible/requirements.yml
                                      - src: /etc/ansible/apple.yml
                                      - src: /etc/ansible/apple.yml
                                      - src: /etc/ansible/roles/geerlineguy
                                      

                                      get rid of the first two entries

                                      DustinB3403D 1 Reply Last reply Reply Quote 0
                                      • DustinB3403D
                                        DustinB3403 @IRJ
                                        last edited by

                                        @IRJ just did, not sure why they're in there as I haven't touched this file.

                                        IRJI 1 Reply Last reply Reply Quote 0
                                        • IRJI
                                          IRJ @DustinB3403
                                          last edited by

                                          @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                          @IRJ just did, not sure why they're in there as I haven't touched this file.

                                          They are there because we did echo command in script to add them.

                                          1 Reply Last reply Reply Quote 0
                                          • DustinB3403D
                                            DustinB3403
                                            last edited by

                                            sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml
                                            - downloading role '/etc/ansible/roles/geerlineguy', owned by
                                             [WARNING]: - /etc/ansible/roles/geerlineguy was NOT installed successfully: Content has no field named 'owner'
                                            
                                            ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
                                            
                                            IRJI 1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 4 / 5
                                            • First post
                                              Last post