Parasitism by bacteriophages has led to the evolution of a variety of defense mechanisms in their host bacteria. However, it is unclear what factors lead to specific defenses being deployed upon phage infection. To explore this question, we exposed the bacterial fish pathogenFlavobacterium columnareto its virulent phage V156 in the presence of a eukaryotic host signal (mucin). All tested conditions led to some level of innate immunity, but the presence of mucin led to a dramatic increase in CRISPR spacer acquisition, especially in low nutrient conditions where over 60% of colonies had obtained at least one new spacer. Additionally, we show that the presence of a competitor bacterium further increases CRISPR spacer acquisition inF. columnare. These results suggest that ecological factors are important in determining defense strategies against phages, and that the concentration of phages on metazoan surfaces may select for the diversification of bacterial immune systems.